FIX: Replaced VLC event.u occurrences

Newer versions of python-vlc have apparently
removed the `event.u` union object from the
events dispatched by the player, resulting in
player callback failures.

The occurrences of `event.u` have therefore
been replaced with the player methods to
correctly retrieve the current state.
This commit is contained in:
Fabio Manganiello 2021-10-17 17:56:57 +02:00
parent f9ce03919b
commit 1906876969
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -130,18 +130,17 @@ class MediaVlcPlugin(MediaPlugin):
self._post_event(MediaStopEvent) self._post_event(MediaStopEvent)
for cbk in self._on_stop_callbacks: for cbk in self._on_stop_callbacks:
cbk() cbk()
elif event.type == EventType.MediaPlayerTitleChanged: elif (
self._filename = event.u.filename event.type == EventType.MediaPlayerTitleChanged or
self._title = event.u.new_title event.type == EventType.MediaPlayerMediaChanged
self._post_event(NewPlayingMediaEvent, resource=event.u.new_title) ):
elif event.type == EventType.MediaPlayerMediaChanged: self._title = self._player.get_title() or self._filename
self._filename = event.u.filename if event.type == EventType.MediaPlayerMediaChanged:
self._title = event.u.new_title self._post_event(NewPlayingMediaEvent, resource=self._title)
self._post_event(NewPlayingMediaEvent, resource=event.u.filename)
elif event.type == EventType.MediaPlayerLengthChanged: elif event.type == EventType.MediaPlayerLengthChanged:
self._post_event(NewPlayingMediaEvent, resource=self._get_current_resource()) self._post_event(NewPlayingMediaEvent, resource=self._get_current_resource())
elif event.type == EventType.MediaPlayerTimeChanged: elif event.type == EventType.MediaPlayerTimeChanged:
pos = float(event.u.new_time/1000) pos = float(self._player.get_time()/1000)
if self._latest_seek is None or \ if self._latest_seek is None or \
abs(pos-self._latest_seek) > 5: abs(pos-self._latest_seek) > 5:
self._post_event(MediaSeekEvent, position=pos) self._post_event(MediaSeekEvent, position=pos)
@ -184,6 +183,7 @@ class MediaVlcPlugin(MediaPlugin):
if resource.startswith('file://'): if resource.startswith('file://'):
resource = resource[len('file://'):] resource = resource[len('file://'):]
self._filename = resource
self._init_vlc(resource) self._init_vlc(resource)
if subtitles: if subtitles:
if subtitles.startswith('file://'): if subtitles.startswith('file://'):