问题
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_())
i can hear only audio playing but no video if i set
self.setWindowFlags(
QtCore.Qt.FramelessWindowHint
| QtCore.Qt.WindowStaysOnTopHint )
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
It also throws a lot of errors but that error does not affect.The errors i got is
[00757578] mmdevice audio output error: cannot initialize COM (error 0x80010106)
[02620b80] mmdevice audio output error: cannot initialize COM (error 0x80010106)
[043ccc28] direct3d11 vout display error: Could not Create the D3D11 device. (hr=0x80004001)
[043ccc28] direct3d11 vout display error: Direct3D11 could not be opened
[043ccc28] direct3d11 vout display error: SetThumbNailClip failed: 0x800706f4
[025fc198] d3d11va generic error: D3D11CreateDevice failed. (hr=0x80004001)
[025fc198] d3d11va generic error: Failed to create device
[043ccc28] direct3d9 vout display error: SetThumbNailClip failed: 0x800706f4
[04384af8] direct3d11 vout display error: Could not Create the D3D11 device. (hr=0x80004001)
[04384af8] direct3d11 vout display error: Direct3D11 could not be opened
[04384af8] direct3d11 vout display error: SetThumbNailClip failed: 0x800706f4
[025fbe38] dxva2 generic error: FindVideoServiceConversion failed
[04384af8] direct3d9 vout display error: SetThumbNailClip failed: 0x800706f4
[04384af8] direct3d11 vout display error: Could not Create the D3D11 device. (hr=0x80004001)
[04384af8] direct3d11 vout display error: Direct3D11 could not be opened
[04384af8] direct3d11 vout display error: SetThumbNailClip failed: 0x800706f4
Does anyone knows how to fix it?
回答1:
This is also an issue at python-VLC github https://github.com/oaubert/python-vlc/issues/155
来源:https://stackoverflow.com/questions/64725900/vlc-wont-work-with-framelesswindow-and-transparent-translucent-background-in-py