I am embedding python vlc in pyqt5 to make a video player.but i am having one problem that is when video starts to play it takes entire taskbar thumbnail to show only its video not other items present in the window screen.And after closing the video the taskbar becomes totally blank white, not showing anything.Here is picture samples. 1-Before Playing
2.When Playing(Look there is no button)
3.After Stopped
I am trying to restore by
QWinThumbnailToolBar in self.videoframe.showEvent()
Here is my Complete Code:
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtWinExtras
import vlc
class Player(QMainWindow):
"""A simple Media Player using VLC and Qt
"""
def __init__(self, master=None):
QMainWindow.__init__(self, master)
self.setWindowTitle("Media Player")
self.mainframe=QFrame(self)
self.setCentralWidget(self.mainframe)
self.videoframe=QFrame(self.mainframe)
self.videoframe.setGeometry(0,50,600,400)
##Call to set taskbar thumbnail
self.videoframe.showEvent=self.setthumbnail
self.instance = vlc.Instance()
self.player = self.instance.media_player_new()
self.player.set_hwnd(int(self.videoframe.winId()))
self.media = self.instance.media_new('C:/Users/mishra/Downloads/Video/kyakar.mp4')
self.player.set_media(self.media)
button=QPushButton('Play',self)
button.setStyleSheet('background:red')
button.setGeometry(100,0,40,30)
button.clicked.connect(lambda:[self.videoframe.show(),self.player.play()])
button1=QPushButton('Close',self)
button1.setStyleSheet('background:green')
button1.setGeometry(200,0,40,30)
button1.clicked.connect(self.onclose)
def onclose(self):
if self.player:
self.player.stop()
self.videoframe.hide()
def setthumbnail(self,event):
print('Shown')
self.thumbbar =QtWinExtras.QWinThumbnailToolBar(self)
self.thumbbar.setWindow(self.windowHandle())
if __name__ == "__main__":
app = QApplication(sys.argv)
player = Player()
player.show()
player.resize(600, 450)
sys.exit(app.exec_())
Is there any way to achieve that?
I marked for you the lines I made the changes. Try it: