Created
February 2, 2018 18:46
-
-
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! ๐
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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