0

I wrote a code that implement vlc player and I want to listen to state change (playing, pause, stop, opening ...) and media duration changing. But I found out that some event works where other doesn't.

instance = vlc.Instance()
media = instance.media_new(src)
self.player = instance.media_player_new()
self.event_manager = self.player.event_manager()

self.event_manager.event_attach(vlc.EventType.MediaStateChanged, self.call_state)
self.event_manager.event_attach(vlc.EventType.MediaPlayerMediaChanged, self.display)


def display(self, event):
    self.show()
 def call_state(self, event):
        print(self.player.get_state())

Here MediaPlayerMediaChanged works fine and MediaStateChanged doesn't.

msakni22
  • 11
  • 3
  • whitch function work and witch doesen't ? – Marcucus _ Jan 15 '22 at 21:20
  • self.event_manager.event_attach(vlc.EventType.MediaPlayerMediaChanged, self.display) this one works – msakni22 Jan 15 '22 at 22:16
  • @msakni22 from the name, it seems like that event is when the *media* state is changed. I'm not sure about what that refers to, but if that's the case, you should probably use the `media.event_manager()` and attach that event type to it. Otherwise, you probably want to attach specific *player* event changes to the player's `event_manager`, like `MediaPlayerPaused`, `MediaPlayerStopped` or `MediaPlayerPlaying`. – musicamante Jan 16 '22 at 00:10
  • yeah, that's the solution that I decided to apply right now, I attached each state change to the same function. Just there's a state called "MediaPlayerOpening" I want to put the media player on that state, is it possible ? – msakni22 Jan 16 '22 at 00:34

0 Answers0