Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaListEndReached event is never triggered #254

Open
hughmcmaster opened this issue May 4, 2023 · 0 comments
Open

MediaListEndReached event is never triggered #254

hughmcmaster opened this issue May 4, 2023 · 0 comments

Comments

@hughmcmaster
Copy link

I've been testing media list events and found that MediaListEndReached is never triggered. MediaListItemAdded and MediaListItemDeleted are triggered correctly, however.

To demonstrate the bug, here is a working example.

Can you please fix this event, as it is would be very useful.

import sys
import vlc
import tkinter as tk
import time

class Player:
    def __init__(self, video=None, args=[]):
        if (sys.platform.startswith('linux')):
            args.append('--no-xlib')

        self.vlc_instance = vlc.Instance(args)
        self.medialist = self.vlc_instance.media_list_new()
        self.mlplayer = self.vlc_instance.media_list_player_new()
        self.player = self.mlplayer.get_media_player()
        self.medialist.add_media(vlc.Media(video))

        self.__set_gui()
        self.__set_bindings()
        
    def __set_gui(self):
        self.root = tk.Tk()
        self.root.minsize(width=800, height=450)
        self.root.protocol('WM_DELETE_WINDOW', self.exit)

        self.videopanel = tk.Frame(self.root)
        self.canvas = tk.Canvas(self.videopanel, bg='red', highlightthickness=0)
        self.canvas.pack(fill=tk.BOTH, expand=1)
        self.videopanel.pack(fill=tk.BOTH, expand=1)

        self.player.set_xwindow(self.videopanel.winfo_id())
        self.root.update()

    def __set_bindings(self):
        self.root.bind('e', lambda event: self.exit())

    def __callback(self, event):
        print(event.type)

    def start(self):
        self.mlplayer.set_media_list(self.medialist)
        self.mlplayer.play()

        self.em = self.medialist.event_manager()
        self.em.event_attach(vlc.EventType.MediaListEndReached, self.__callback)
        self.root.mainloop()

    def exit(self):
        self.mlplayer.stop()
        self.root.quit()
        self.root.destroy()


player = Player(video='video.mp4', args=['--no-autoscale'])
player.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant