def __init__(self, frame_action=None, finish_action=None, **kwargs): super(VideoPlayerWidget, self).__init__(**kwargs) if frame_action is None: self.frame_action = self.default_frame else: self.frame_action = frame_action if finish_action is None: self.finish_action = self.default_finish else: self.finish_action = finish_action self.ui = Ui_EmotionVideoPlayer() self.ui.setupUi(self) self.backgroundPalette = QtGui.QPalette() self.backgroundPalette.setColor(QtGui.QPalette.Background, QtGui.QColor(0, 0, 0)) self.setAutoFillBackground(True) self.setPalette(self.backgroundPalette) self.ui.videoPlayer = QtMultimediaWidgets.QVideoWidget() self.ui.gridLayout.addWidget(self.ui.videoPlayer, 1, 1, 1, 1) self.mediaPlayer = QtMultimedia.QMediaPlayer( self, QtMultimedia.QMediaPlayer.VideoSurface) self.video_item = QtMultimediaWidgets.QGraphicsVideoItem() self.mediaPlayer.setVideoOutput(self.ui.videoPlayer) self.mediaPlayer.mediaStatusChanged.connect(self.status_check) self.frameProbe = QtMultimedia.QVideoProbe(self) # self.frameProbe.videoFrameProbed.connect(self.frame) self.frameProbe.setSource(self.mediaPlayer) self.frame_number = 0 self.video = None
def __init__(self, source): Media.__init__(self, Media.TYPE_VIDEO, source) DisplayObject.__init__(self) self._videoGraphicsItem = QtMultimediaWidgets.QGraphicsVideoItem() self._videoGraphicsItem.setAspectRatioMode(QtCore.Qt.IgnoreAspectRatio) self._videoGraphicsItem._nativeSizeChangedSlot = lambda size: self._onVideoNativeSizeChanged( size) self._videoGraphicsItem.nativeSizeChanged.connect( self._videoGraphicsItem._nativeSizeChangedSlot) self.source.setVideoOutput(self._videoGraphicsItem)