I need to do a video player in PyQt. What is special at this video player is that I need 2 windows with the same video one in my interface and another in another monitor and both should be controlled from interface. I reused to do one separate widow with the video(that where the bird is), but I can't handle to do another one in that white widget. This is the code:
self.player = QMediaPlayer() self.player.play() # Setup the playlist. self.playlist = QMediaPlaylist() self.player.setPlaylist(self.playlist) # # Add viewer for video playback, separate floating window. self.viewer = ViewerWindow(self) self.viewer.setWindowFlags(self.viewer.windowFlags() | Qt.WindowStaysOnTopHint) self.viewer.setMinimumSize(QSize(480, 360)) self.viewer.setWindowTitle("VR Therapy") self.videoWidget = QVideoWidget(self) self.viewer.setCentralWidget(self.videoWidget) self.player.setVideoOutput(self.videoWidget) # Connect control buttons/slides for media player. self.playButton_2.pressed.connect(self.player.play) self.pauseButton_2.pressed.connect(self.player.pause) self.stopButton_2.clicked.connect(self.player.stop) self.volumeSlider_2.valueChanged.connect(self.player.setVolume) self.viewButton_2.toggled.connect(self.toggle_viewer) self.viewer.state.connect(self.viewButton_2.setChecked) self.previousButton_2.pressed.connect(self.playlist.previous) self.nextButton_2.pressed.connect(self.playlist.next) self.model = PlaylistModel(self.playlist) self.playlistView_2.setModel(self.model) self.playlist.currentIndexChanged.connect(self.playlist_position_changed) selection_model = self.playlistView_2.selectionModel() selection_model.selectionChanged.connect(self.playlist_selection_changed) self.player.durationChanged.connect(self.update_duration) self.player.positionChanged.connect(self.update_position) self.timeSlider_2.valueChanged.connect(self.player.setPosition) videoplayer
