linuxmint / hypnotix

An M3U IPTV Player
1.26k stars 168 forks source link

Avoid race condition playing local content #172

Closed lulol closed 3 years ago

lulol commented 3 years ago

# https://github.com/jaseg/python-mpv#pygobject-embedding # Must be created >after< the widget is shown, else property 'window' will be None

Wait for window to get ready before retrieving properties and playing content to avoid failures with local content.

lulol commented 3 years ago

*Urgh* Sorry for the mess. Hope you squash all these commits. :(

superolmo commented 3 years ago

I like the idea, but that is a dangerous loop that could never end. Maybe adding a simple counter up to a value in seconds will guarantee that the wait is no longer than N seconds. Also, just throwing ideas here, it would be nice to show that the process is waiting in the loop by maybe temporarily change the box color around the MPV window or some other visual indications.

lulol commented 3 years ago

You are right. Added a Gtk.events_pending() to handle main loop events while waiting, that I think that may be a better approach than a fixed timeout, but my Gtk knowledge is *very* limited.

Already had tried calling the main gtk loop after the sleep with Gtk.main_iteration_do(False) but that didn't seem to do anything.

The UI already shows a spinner in the widget window before mpv tries to start displaying the content before the window is created. But I guess that you always can press the back button and try again like sometimes is needed now without this patch.