i am making a window which plays video with vlc. Here is my code
from PyQt5 import QtWidgets,QtCore,QtGui
import vlc
class Player(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.resize(600,400)
self.mainframe=QtWidgets.QFrame(self)
self.setCentralWidget(self.mainframe)
self.mainframe.setStyleSheet("background:grey;border-radius:15px;")
self.videoframe=QtWidgets.QFrame(self.mainframe)
self.videoframe.setGeometry(10,10,580,380)
self.videoframe.setStyleSheet("background:#333333")
'''
If i want to set transparent background and frameless window,video wont display only audio plays
'''
# self.setWindowFlags(
# QtCore.Qt.FramelessWindowHint
# | QtCore.Qt.WindowStaysOnTopHint )
# self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
self.instance=vlc.Instance()
self.player = self.instance.media_player_new()
self.player.set_hwnd(int(self.videoframe.winId()))
media = self.instance.media_new('C:/Users/mishra/Downloads/Video/despacito.mp4')
media.parse()
self.player.set_media(media)
self.player.play()
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
window = Player()
window.show()
sys.exit(app.exec_())
这也是 python-VLC github https://github.com/oaubert/python-vlc/issues/155 的一个问题
Here is a clue, maybe: I get the same issue with the actual VLC application, 3.0.16.
It happens only when I enable Qt as my interface of choice.
Sounds like it isn't a problem with your code, but with the libVLC library's use of Qt.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.