You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good afternoon everyone, I am writing a script that, when launched, plays a video by its number. Then, after the end of playback, the script asks for the video number for the next playback, and so on.
`
import sys
import time
import vlc
from PyQt5 import QtGui, QtWidgets
from PyQt5.QtCore import Qt
class Player(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(Player, self).__init__(parent)
self.setWindowTitle("Media Player")
# creating a basic vlc instance
self.instance = vlc.Instance(['--video-on-top'])
self.instance.log_unset()
self.media=None
self.mediaplayer = self.instance.media_player_new()
self.create_ui()
self.open_file()
def create_ui(self):
self.videoframe = QtWidgets.QFrame(
frameShape=QtWidgets.QFrame.Box, frameShadow=QtWidgets.QFrame.Raised)
if sys.platform.startswith("linux"): # for Linux using the X Server
self.mediaplayer.set_xwindow(self.videoframe.winId())
elif sys.platform == "win32": # for Windows
self.mediaplayer.set_hwnd(self.videoframe.winId())
elif sys.platform == "darwin": # for MacOS
self.mediaplayer.set_nsobject(self.videoframe.winId())
central_widget = QtWidgets.QWidget()
self.setCentralWidget(central_widget)
self.setWindowFlags(Qt.FramelessWindowHint)
lay = QtWidgets.QVBoxLayout(central_widget)
lay.addWidget(self.videoframe)
def play(self):
if self.mediaplayer.play() == -1:
self.open_file()
self.mediaplayer.play()
def open_file(self):
numberfile = input("File number: ")
filename = (f"/home/Tadont/Video/{numberfile}.mp4")
self.media = self.instance.media_new(filename)
self.mediaplayer.set_media(self.media)
self.eventManager=self.mediaplayer.event_manager()
self.eventManager.event_attach(vlc.EventType.MediaPlayerEndReached, self.next_file)
self.play()
def next_file(self, event):
if event.type == vlc.EventType.MediaPlayerEndReached:
#self.mediaplayer.stop()
self.open_file()
Good afternoon everyone, I am writing a script that, when launched, plays a video by its number. Then, after the end of playback, the script asks for the video number for the next playback, and so on.
`
import sys
import time
import vlc
from PyQt5 import QtGui, QtWidgets
from PyQt5.QtCore import Qt
class Player(QtWidgets.QMainWindow):
def main():
app = QtWidgets.QApplication(sys.argv)
player = Player()
player.show()
player.move(1, 1)
player.resize(406, 86)
player.setObjectName("MainWindow")
player.setStyleSheet("#MainWindow{background-color:black}")
sys.exit(app.exec_())
if name == "main":
main()`
I have the first file to play, then I write the file number for the second playback, but the second file does not start. How to solve this problem?
The text was updated successfully, but these errors were encountered: