Skip to content

Instantly share code, notes, and snippets.

@candh
Created February 2, 2018 18:46
Show Gist options
  • Save candh/cbef9ab3f52e4d4db0ff1ec2fd0b3d37 to your computer and use it in GitHub Desktop.
Save candh/cbef9ab3f52e4d4db0ff1ec2fd0b3d37 to your computer and use it in GitHub Desktop.
[vlc events example] This example checks if the song/media has stopped using the vlc's amazing python library. Also using pyqt here makes an event loop so be careful if you're running this without an event loop, the script will just quit! ๐Ÿ™‚
from PyQt5.QtWidgets import *
import vlc
class App(QMainWindow):
def __init__(self):
super().__init__()
self.init()
def init(self):
self.setGeometry(40, 40, 500, 500)
self.setWindowTitle("Test")
songs = ["Let It Happen.flac", "Nangs.flac"]
player = vlc.MediaPlayer(songs[0])
player.play()
eventmngr = player.event_manager()
eventmngr.event_attach(vlc.EventType.MediaPlayerEndReached, self.song_end)
self.show()
def song_end(self, *args, **kwargs):
print("woah song ended")
app = QApplication([])
myapp = App()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment