0

In the following code

# python-vlc
from vlc import Media, MediaPlayer, EventType, Event

class MusicPlayer:
    def __init__(self) -> None:
        self.items = ["/list/of/path/to/audio/file"]
        self.index = 0
        self.player: MediaPlayer = MediaPlayer(self.items[self.index])
        event_manager = self.player.event_manager()
        event_manager.event_attach(EventType.MediaPlayerEndReached, self.handleLoop)
    def change(self):
        self.player.stop()
        self.player.set_media(Media(self.items[self.index]))
        self.player.play()
    def play(self):
        self.player.play()
    def handleLoop(self, event):
        self.index += 1
        print('Play Ended')
        self.change(self.index)

When the media play is over the handleLoop is supposed to get triggered and it does but when it get triggered only these two lines get executed, self.index += 1 and print('Play Ended'). self.change(self.index) method doesn't gets executed. I am not even get any error. I tried attaching event for error and still got nothing.

Do anyone knows solution to that?

  • 1
    It looks like you're passing `self.index` as an argument for `self.change()` when it only takes the argument `self`. You should probably be getting an error, but try removing that anyway. – MillerTime Mar 13 '23 at 18:22

0 Answers0