I am trying to make a simple media player in PyQt5 ,QMediaPlayer which can play video on user input. But whenever i to play the next video, there is always a moment of black screen in between. Is there any way to go around this?
from tkinter.ttk import Style
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer
from PyQt5.QtMultimediaWidgets import QVideoWidget
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Laz")
self.setFixedSize(1900, 1070)
self.vid = QVideoWidget()
self.setCentralWidget(self.vid)
self.mediawidg = QMediaPlayer(None, QMediaPlayer.VideoSurface)
def it(self):
while True:
self.vid.setStyleSheet(" QVideoWidget {background-image: url('b.png')}")
wd = input("Say:")
self.mediawidg.setVideoOutput(self.vid)
self.mediawidg.setMedia(QMediaContent(QUrl(str(wd+".mkv"))))
self.mediawidg.play()
stylesheet = """
MainWindow {
background-image: url("b.png");
background-repeat: no-repeat;
background-position: center;
}
"""
app = QApplication(sys.argv)
app.setStyleSheet(stylesheet)
window = MainWindow()
window.show()
window.it()
app.exec()```