def __init__(self, url=None, parent=None): QWidget.__init__(self) self.setWindowTitle('Video Player') # 再生ファイル self.url = url # Phonon Objects # *************** self.media = Phonon.MediaObject(self) self.video = Phonon.VideoWidget(self) # self.video.setMinimumSize(180, 280) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) # Timer # ***** self.media.setTickInterval(1 / 30 * 1000) # [ms] self.media.tick.connect(self.tock) self.time = 0 # UI 生成 # *************** self.setupUI()
def __init__(self): super(MainWindow, self).__init__() self.media = Phonon.MediaObject(self) self.audio = Phonon.AudioOutput(Phonon.MusicCategory, self) self.video = Phonon.VideoWidget(self) self.metaInformationResolver = Phonon.MediaObject(self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) self.media.setTickInterval(1000) self.sources = [] self.setupActions() self.setupConnections() self.setupUi() self.setWindowTitle("BLue PLayer") self.setMinimumSize(245,245) self.resize(680,400)
def setup(self, parent): self.media = Phonon.MediaObject(parent) videoWidget = Phonon.VideoWidget(parent) Phonon.createPath(self.media, videoWidget) self.layout().addWidget(videoWidget) self.seekSlider = Phonon.SeekSlider(self.media, parent) self.layout().addWidget(self.seekSlider) self.seekSlider.setIconVisible(False) self.media.finished.connect(self.mediaFinished)
def get_widget_player(file_path, audio): media_src = Phonon.MediaSource(file_path) media_obj = Phonon.MediaObject() media_obj.setCurrentSource(media_src) video_widget = Phonon.VideoWidget() Phonon.createPath(media_obj, video_widget) if audio: audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(media_obj, audio_out) return media_obj, video_widget
def init_video(main_window): file_path = Utilities.OUTPUT_FOLDER + Utilities.CAMERA_FILE media_src = Phonon.MediaSource(file_path) main_window.media_obj = Phonon.MediaObject(main_window.wdgVideo) main_window.media_obj.setCurrentSource(media_src) main_window.video_widget = Phonon.VideoWidget(main_window.wdgVideo) Phonon.createPath(main_window.media_obj, main_window.video_widget) main_window.video_widget.setGeometry(main_window.wdgVideo.geometry()) main_window.video_widget.show() main_window.media_obj.play() main_window.media_obj.pause()
def play(self, filepath): global video_widget media_source = Phonon.MediaSource(filepath) media_obj = Phonon.MediaObject() media_obj.setCurrentSource(media_source) video_widget = Phonon.VideoWidget() Phonon.createPath(media_obj, video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(media_obj, audio_out) video_widget.show() media_obj.play()
def __init__(self, parent=None): QMainWindow.__init__(self, parent) # create two video widgets central = QWidget(self) self.setCentralWidget(central) layout = QHBoxLayout(central) central.setLayout(layout) self.left_video = Phonon.VideoWidget(self) self.right_video = Phonon.VideoWidget(self) layout.addWidget(self.left_video) layout.addWidget(self.right_video) # the media object controlling the video playback self.media = Phonon.MediaObject(self) # the audio sink self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) # connect the media object with audio and *left* video Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.left_video) # holds the Path object, that connects self.media with self.right_video self.right_path = None self.actions_toolbar = self.addToolBar('Actions') self._actions = {} for name, label, icon_name in self.ACTIONS: if icon_name: icon = self.style().standardIcon(icon_name) action = QAction(icon, label, self) else: action = QAction(label, self) action.setObjectName(name) if name in ('play', 'pause', 'stop'): action.triggered.connect(getattr(self.media, name)) else: action.triggered.connect(getattr(self, name)) self.actions_toolbar.addAction(action) self._action('remove_right_video').setEnabled(False)
def __init__(self): #QtGui.QWidget.__init__(self) super(QPlayer, self).__init__() self.audioOuptut = Phonon.AudioOutput(Phonon.MusicCategory, self) self.player = Phonon.MediaObject(self) Phonon.createPath(self.player, self.audioOuptut) self.videoWidget = Phonon.VideoWidget(self) Phonon.createPath(self.player, self.videoWidget) self.player.setTickInterval(1000) self.connect(self.player, QtCore.SIGNAL("tick(qint64)"), self.tick) self.seekSlider = Phonon.SeekSlider(self.player, self) self.volumeSlider = Phonon.VolumeSlider(self.audioOuptut, self) self.buildGUI() self.setupConnections()
def agregaCustomVideo(self): largo = 1904 if self.settingsPantallas[self.pantalla][2] == None: self.settingsPantallas[self.pantalla][2] = 1 multiplicador = self.settingsPantallas[self.pantalla][2] if multiplicador == 2: largo = 3820 if multiplicador == 3: largo = 5740 if multiplicador == 4: largo = 7660 customVideo, _ = QFileDialog.getOpenFileName(self, 'Cargar video') self.pantallaActiva.frame.setGeometry(0, 0, largo, 1050) self.pantallaActiva.titleFrame.setVisible(False) self.pantallaActiva.graphFrame.setVisible(False) self.pantallaActiva.fotosFrame.setVisible(False) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) media_src = Phonon.MediaSource(customVideo) self.pantallaActiva.media_obj = Phonon.MediaObject( self.pantallaActiva.frame) self.pantallaActiva.media_obj.setCurrentSource(media_src) self.pantallaActiva.video_widget = Phonon.VideoWidget( self.pantallaActiva.frame) self.pantallaActiva.video_widget.setGeometry(0, 0, largo, 1050) Phonon.createPath(self.pantallaActiva.media_obj, self.pantallaActiva.video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantallaActiva.media_obj, audio_out) self.pantallaActiva.video_widget.show() self.pantallaActiva.media_obj.play() self.settingsPantallas[self.pantalla][0] = "customVideo" self.settingsPantallas[self.pantalla][1] = customVideo self.settingsPantallas[self.pantalla][2] = multiplicador
def agregaCustomVideo(self): self.guion = False if self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] == None: self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] = 1 multiplicador = self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] self.extiendePantalla(multiplicador) largo = 1920 * multiplicador customVideo, _ = QFileDialog.getOpenFileName(self, 'Cargar video') #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) media_src = Phonon.MediaSource(customVideo) self.pantallaActiva.media_obj = Phonon.MediaObject( self.pantallaActiva.frame) self.pantallaActiva.media_obj.setCurrentSource(media_src) self.pantallaActiva.video_widget = Phonon.VideoWidget( self.pantallaActiva.frame) self.pantallaActiva.video_widget.setGeometry(0, 0, largo, 1080) Phonon.createPath(self.pantallaActiva.media_obj, self.pantallaActiva.video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantallaActiva.media_obj, audio_out) self.pantallaActiva.video_widget.show() self.pantallaActiva.media_obj.play() self.settingsPantallas[ self.pantallaActivaIndex]['type'] = "customVideo" self.settingsPantallas[self.pantallaActivaIndex]['path'] = customVideo self.settingsPantallas[ self.pantallaActivaIndex]['multiplicador'] = multiplicador
def __init__(self): QtGui.QWidget.__init__(self) self.setWindowTitle('Video Player') self.media = Phonon.MediaObject(self) self.video = Phonon.VideoWidget(self) self.video.setMinimumSize(400, 400) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) self.buttonChoose = QtGui.QPushButton('Choose File', self) self.buttonMimes = QtGui.QPushButton('Show Mimetypes', self) self.slider = Phonon.VolumeSlider(self) self.slider.setAudioOutput(self.audio) layout = QtGui.QGridLayout(self) layout.addWidget(self.video, 0, 0, 1, 2) layout.addWidget(self.buttonChoose, 1, 0) layout.addWidget(self.buttonMimes, 1, 1) layout.addWidget(self.slider, 2, 0, 1, 2) layout.setRowStretch(0, 1) self.media.stateChanged.connect(self.handleStateChanged) self.buttonChoose.clicked.connect(self.handleButtonChoose) self.buttonMimes.clicked.connect(self.handleButtonMimes)
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA import os from PySide.QtGui import QApplication from PySide.phonon import Phonon app = QApplication([]) app.setApplicationName('Phonon Video Player') #file_path = os.path.join(os.path.dirname(__file__), '320x240.ogv') file_path = os.path.join(os.path.dirname(__file__), 'FolgersCoffe_512kb_mp4_026vbr260.ogv') media_src = Phonon.MediaSource(file_path) media_obj = Phonon.MediaObject() media_obj.setCurrentSource(media_src) video_widget = Phonon.VideoWidget() Phonon.createPath(media_obj, video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(media_obj, audio_out) video_widget.show() media_obj.play() app.exec_()
def ponPantallasAsi(self): print(str(self.settingsPantallas)) estabaEnLaPantalla = self.pantallaActivaIndex for p in range(0, self.numeroDePantallas): self.pantallaActiva = self.pantalla[p] self.pantallaActivaIndex = p if ("custom" in str( self.settingsPantallas[self.pantallaActivaIndex][0])) or ( str(self.settingsPantallas[self.pantallaActivaIndex] [0]).isdigit()): if str(self.settingsPantallas[self.pantallaActivaIndex] [0]).isdigit(): print("serie") print(str( self.settingsPantallas[self.pantallaActivaIndex])) print( "poniendo el slider en " + str(self.settingsPantallas[ self.pantallaActivaIndex][3])) self.sliderObservados.setVisible(True) self.fechaSlider.setFocus() self.extiendePantalla( self.settingsPantallas[self.pantallaActivaIndex][2]) if self.pantallaActiva.video_widget: self.pantallaActiva.video_widget.resize(0, 0) print(str( self.settingsPantallas[self.pantallaActivaIndex])) #self.fechaSlider.setMaximum(self.settingsPantallas[self.pantallaActivaIndex][0]) self.ponFecha( self.settingsPantallas[self.pantallaActivaIndex][3]) if self.settingsPantallas[ self.pantallaActivaIndex][0] == "customVideo": largo = self.settingsPantallas[ self.pantallaActivaIndex][2] * 1920 self.extiendePantalla( self.settingsPantallas[self.pantallaActivaIndex][2]) self.pantallaActiva.frame.setGeometry(0, 0, largo, 1080) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) customVideo = self.settingsPantallas[ self.pantallaActivaIndex][1] media_src = Phonon.MediaSource(customVideo) self.pantallaActiva.media_obj = Phonon.MediaObject( self.pantallaActiva.frame) self.pantallaActiva.media_obj.setCurrentSource(media_src) self.pantallaActiva.video_widget = Phonon.VideoWidget( self.pantallaActiva.frame) self.pantallaActiva.video_widget.setGeometry( 0, 0, largo, 1050) Phonon.createPath(self.pantallaActiva.media_obj, self.pantallaActiva.video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantallaActiva.media_obj, audio_out) self.pantallaActiva.video_widget.show() self.pantallaActiva.media_obj.play() if self.settingsPantallas[ self.pantallaActivaIndex][0] == "customImage": print("aqui se agrega una imagen custom") customImage = self.settingsPantallas[ self.pantallaActivaIndex][1] estaImagen = QImage(customImage) multiplicador = self.settingsPantallas[ self.pantallaActivaIndex][2] self.extiendePantalla(multiplicador) try: if self.pantallaActiva.video_widget: self.pantallaActiva.video_widget.resize(0, 0) self.pantallaActiva.imageCanvas.setPixmap( QPixmap.fromImage(estaImagen)) except: print("no pude") elif (str(self.settingsPantallas[self.pantallaActivaIndex][0]) == "webSerie"): print("serie") print(str(self.settingsPantallas[self.pantallaActivaIndex])) print("poniendo el slider en " + str(self.settingsPantallas[self.pantallaActivaIndex][3])) self.sliderObservados.setVisible(True) self.fechaSlider.setFocus() self.extiendePantalla( self.settingsPantallas[self.pantallaActivaIndex][2]) if self.pantallaActiva.video_widget: self.pantallaActiva.video_widget.resize(0, 0) print(str(self.settingsPantallas[self.pantallaActivaIndex])) #self.fechaSlider.setMaximum(self.settingsPantallas[self.pantallaActivaIndex][0]) self.ponFecha( self.settingsPantallas[self.pantallaActivaIndex][3]) else: print("no es nada") self.pantallaActiva = self.pantalla[estabaEnLaPantalla] self.pantallaActivaIndex = estabaEnLaPantalla
def ponPantallasAsi(self): print(str(self.settingsPantallas)) self.guion = True estabaEnLaPantalla = self.pantallaActivaIndex self.groupsOfTimeSisters = [] self.groupsOfSpaceSisters = [] self.cargando = [False for i in range(0, self.numeroDePantallas)] for x in range(0, self.numeroDePantallas): if self.settingsPantallas[x]['type'] == "serieWeb": self.cargando[x] = True for p in range(0, self.numeroDePantallas): ya = False for i in range(0, len(self.groupsOfTimeSisters)): if p in self.groupsOfTimeSisters[i]: ya = True if not ya and len(self.settingsPantallas[p]['timeSisters']) > 0: lista = self.settingsPantallas[p]['timeSisters'][:] lista.append(p) self.groupsOfTimeSisters.append(lista) ya = False for i in range(0, len(self.groupsOfSpaceSisters)): if p in self.groupsOfSpaceSisters[i]: ya = True if not ya and len(self.settingsPantallas[p]['spaceSisters']) > 0: lista = self.settingsPantallas[p]['spaceSisters'][:] lista.append(p) self.groupsOfSpaceSisters.append(lista) if self.settingsPantallas[p]['type'] == "imageSerie": print("imageSerie") print(str(self.settingsPantallas[p])) print("poniendo el slider en " + str(self.settingsPantallas[p]['initialFrame'])) self.sliderObservados.setVisible(True) self.fechaSlider.setFocus() self.extiendePantallaNoActiva( p, self.settingsPantallas[p]['multiplicador']) if self.pantalla[p].video_widget: self.pantalla[p].video_widget.resize(0, 0) print(str(self.settingsPantallas[p])) #self.fechaSlider.setMaximum(self.settingsPantallas[self.pantallaActivaIndex][0]) self.ponFecha(self.settingsPantallas[p]['initialFrame']) elif self.settingsPantallas[p]['type'] == "customVideo": largo = self.settingsPantallas[p]['multiplicador'] * 1920 self.extiendePantallaNoActiva( p, self.settingsPantallas[p]['multiplicador']) self.pantalla[p].frame.setGeometry(0, 0, largo, 1080) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) customVideo = self.settingsPantallas[p]['path'] media_src = Phonon.MediaSource(customVideo) self.pantalla[p].media_obj = Phonon.MediaObject( self.pantalla[p].frame) self.pantalla[p].media_obj.setCurrentSource(media_src) self.pantalla[p].video_widget = Phonon.VideoWidget( self.pantalla[p].frame) self.pantalla[p].video_widget.setGeometry(0, 0, largo, 1050) Phonon.createPath(self.pantalla[p].media_obj, self.pantalla[p].video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantalla[p].media_obj, audio_out) self.pantalla[p].video_widget.show() self.pantalla[p].media_obj.play() elif self.settingsPantallas[p]['type'] == "customImage": print("aqui se agrega una imagen custom " + self.settingsPantallas[p]['path'] + " en la pantalla " + str(p)) customImage = str(self.settingsPantallas[p]['path']) estaImagen = QImage(customImage) multiplicador = self.settingsPantallas[p]['multiplicador'] self.extiendePantallaNoActiva(p, multiplicador) try: if self.pantalla[p].video_widget: self.pantalla[p].video_widget.resize(0, 0) self.pantalla[p].imageCanvas.setPixmap( QPixmap.fromImage(estaImagen)) self.pantalla[p].view.hide() except: print("no pude") elif self.settingsPantallas[p]['type'] == "webPage": print("webPage") print(str(self.settingsPantallas[p])) self.extiendePantallaNoActiva( p, self.settingsPantallas[p]['multiplicador']) self.settingsPantallas[p]['numberOfFrames'] = 1 self.pantalla[p].numberOfFrames = 1 self.pantalla[p].setSimpleWebKit( self.settingsPantallas[p]['path']) if self.pantalla[p].video_widget: self.pantalla[p].video_widget.resize(0, 0) #self.ponFecha(self.settingsPantallas[self.pantallaActivaIndex]['initialFrame']) else: print("no es nada") if True in self.cargando: #elif self.settingsPantallas[p]['type']=="serieWeb": self.ponSiguienteSerieWeb() self.pantallaActiva = self.pantalla[estabaEnLaPantalla] self.pantallaActivaIndex = estabaEnLaPantalla
def ponPantallasAsi(self): print(str(self.settingsPantallas)) estabaEnLaPantalla = self.pantalla for panta in range(0, 6): print("pantalla " + str(panta + 1)) if panta == 0: self.pantallaActiva = self.Pantalla1 if panta == 1: self.pantallaActiva = self.Pantalla2 if panta == 2: self.pantallaActiva = self.Pantalla3 if panta == 3: self.pantallaActiva = self.Pantalla4 if panta == 4: self.pantallaActiva = self.Pantalla5 if panta == 5: self.pantallaActiva = self.Pantalla6 self.pantalla = panta if ("custom" in str( self.settingsPantallas[self.pantalla][0])) or (str( self.settingsPantallas[self.pantalla][0]).isdigit()): if str(self.settingsPantallas[self.pantalla][0]).isdigit(): print("serie") print(str(self.settingsPantallas[self.pantalla])) print("poniendo el slider en " + str(self.settingsPantallas[self.pantalla][3])) self.sliderObservados.setVisible(True) self.fechaSlider.setFocus() largo = 1904 if self.settingsPantallas[self.pantalla][2] == 2: largo = 3820 self.pantallaX2() if self.settingsPantallas[self.pantalla][2] == 3: largo = 5740 self.pantallaX3() if self.settingsPantallas[self.pantalla][2] == 4: largo = 7660 self.pantallaX4() if largo == 1904: self.pantallaX1() self.pantallaActiva.frame.setGeometry(0, 0, largo, 1050) self.pantallaActiva.titleFrame.setVisible(False) self.pantallaActiva.graphFrame.setVisible(False) self.pantallaActiva.fotosFrame.setVisible(False) #self.fechaSlider.setValue(self.settingsPantallas[self.pantalla][3]) #self.ponFecha(self.settingsPantallas[self.pantalla][3]) #self.fechaSlider.setValue(self.settingsPantallas[self.pantalla][3]) if self.pantallaActiva.video_widget: size = self.pantallaActiva.video_widget.size() self.pantallaActiva.video_widget.resize(0, 0) print(str(self.settingsPantallas[self.pantalla])) #self.fechaSlider.setMaximum(self.settingsPantallas[self.pantalla][0]) self.ponFecha(self.settingsPantallas[self.pantalla][3]) if self.settingsPantallas[self.pantalla][0] == "customVideo": largo = 1904 if self.settingsPantallas[self.pantalla][2] == 2: largo = 3820 self.pantallaX2() if self.settingsPantallas[self.pantalla][2] == 3: largo = 5740 self.pantallaX3() if self.settingsPantallas[self.pantalla][2] == 4: largo = 7660 self.pantallaX4() if largo == 1904: self.pantallaX1() self.pantallaActiva.frame.setGeometry(0, 0, largo, 1050) self.pantallaActiva.titleFrame.setVisible(False) self.pantallaActiva.graphFrame.setVisible(False) self.pantallaActiva.fotosFrame.setVisible(False) self.controlesVideo.setVisible(True) #self.pantallaActiva.mapFrame.setGeometry(0,0,1900,1050) customVideo = self.settingsPantallas[self.pantalla][1] media_src = Phonon.MediaSource(customVideo) self.pantallaActiva.media_obj = Phonon.MediaObject( self.pantallaActiva.frame) self.pantallaActiva.media_obj.setCurrentSource(media_src) self.pantallaActiva.video_widget = Phonon.VideoWidget( self.pantallaActiva.frame) self.pantallaActiva.video_widget.setGeometry( 0, 0, largo, 1050) Phonon.createPath(self.pantallaActiva.media_obj, self.pantallaActiva.video_widget) audio_out = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.pantallaActiva.media_obj, audio_out) self.pantallaActiva.video_widget.show() self.pantallaActiva.media_obj.play() if self.settingsPantallas[self.pantalla][0] == "customImage": print("aqui se agrega una imagen custom") customImage = self.settingsPantallas[self.pantalla][1] estaImagen = QImage(customImage) largo = 1904 if self.settingsPantallas[self.pantalla][2] == 2: largo = 3820 self.pantallaX2() if self.settingsPantallas[self.pantalla][2] == 3: largo = 5740 self.pantallaX3() if self.settingsPantallas[self.pantalla][2] == 4: largo = 7660 self.pantallaX4() if largo == 1904: self.pantallaX1() self.pantallaActiva.frame.setGeometry(0, 0, largo, 1050) self.pantallaActiva.mapFrame.setGeometry(0, 0, largo, 1050) self.pantallaActiva.titleFrame.setVisible(False) self.pantallaActiva.graphFrame.setVisible(False) self.pantallaActiva.fotosFrame.setVisible(False) try: if self.pantallaActiva.video_widget: size = self.pantallaActiva.video_widget.size() self.pantallaActiva.video_widget.resize(0, 0) #self.pantallaActiva.video_widget.resize(size) self.pantallaActiva.mapFrame.setPixmap( QPixmap.fromImage(estaImagen)) except: print("no pude") else: print("no es nada") if estabaEnLaPantalla == 0: self.pantallaActiva = self.Pantalla1 if estabaEnLaPantalla == 1: self.pantallaActiva = self.Pantalla2 if estabaEnLaPantalla == 2: self.pantallaActiva = self.Pantalla3 if estabaEnLaPantalla == 3: self.pantallaActiva = self.Pantalla4 if estabaEnLaPantalla == 4: self.pantallaActiva = self.Pantalla5 if estabaEnLaPantalla == 5: self.pantallaActiva = self.Pantalla6 self.pantalla = estabaEnLaPantalla
def setupUi(self, parent): """ Overridden setup UI method. :type parent: MainApp """ super(MainApp, self).setupUi(parent) self.videoNameLlb.setText(str(self.video.name)) self.zoomlSlider.setMinimumWidth(50) self.userLbl.setText(self.user.email) self.setWindowFlags(self.windowFlags() ^ Qt.WindowContextHelpButtonHint) self.setWindowTitle(self.windows_title) # fill video properties self.videoTable.setItem(0, 1, QTableWidgetItem(self.video.name)) self.videoTable.setItem(1, 1, QTableWidgetItem(self.video.filename)) self.videoTable.setItem(2, 1, QTableWidgetItem(str(self.video.width) + "x" + str(self.video.height))) self.videoTable.setItem(3, 1, QTableWidgetItem("%s fps (%s frames)" % (self.video.fps, self.video.frame_count))) timeInSec = self.video.duration ms = round((timeInSec - int(timeInSec)) * 1000) if ms >= 1000: ms = 0 timeInSec += 1 hms = time.strftime('%H:%M:%S', time.gmtime(timeInSec)) self.timeLbl.setText("%s:%03d" % (hms, ms)) self.videoTable.setItem(4, 1, QTableWidgetItem("%s.%03d" % (hms, ms))) self.videoTable.setItem(5, 1, QTableWidgetItem("No" if self.video.is_finished else "Yes")) # setup annotation table geometry header = self.annotationsTable.horizontalHeader() header.setResizeMode(0, QHeaderView.Interactive) header.setResizeMode(1, QHeaderView.Stretch) header.setResizeMode(2, QHeaderView.ResizeToContents) self.annotationsTable.setColumnWidth(0, 230) self.annotationsTable.setColumnWidth(2, 35) # setup nonVis annotation table self.nonVisTable.setMouseTracking(True) font = self.nonVisTable.font() font.setPixelSize(self.SMALL_FONT) self.nonVisTable.setFont(font) header = self.nonVisTable.verticalHeader() header.setResizeMode(QHeaderView.ResizeToContents) header = self.nonVisTable.horizontalHeader() header.setResizeMode(QHeaderView.Fixed) # graphicsView init self.scene = graphics.GraphicsScene(self) self.graphicsView.setStyleSheet("background: #000000") self.graphicsView.setAlignment(Qt.AlignLeft | Qt.AlignTop) self.graphicsView.setScene(self.scene) self.graphicsView.resizeEvent = self.graphicsViewResizeEvent self.graphicsView.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.videoGridLayout.setAlignment(self.graphicsView, Qt.AlignCenter) # Setup multimedia player path = os.path.join(self.rootPath, 'data', 'video', self.video.filename) self.audioOuptut = Phonon.AudioOutput(Phonon.MusicCategory, self) self.videoWidget = Phonon.VideoWidget() self.player = videoplayer.VideoPlayer(self, path) Phonon.createPath(self.player, self.audioOuptut) Phonon.createPath(self.player, self.videoWidget) self.playerProxy = self.scene.addWidget(self.videoWidget) self.playerProxy.setVisible(False) self.scene.video_size = self.playerProxy.size() # setup player controls self.mainSeekSlider = videoplayer.MainVideoSeeker(self) self.mainSeekSlider.setMinimumWidth(100) self.volumeSlider = Phonon.VolumeSlider(self.audioOuptut) self.volumeSlider.setFixedWidth(100) self.mainVideoBarHLayout.addWidget(self.mainSeekSlider) self.mainVideoBarHLayout.addWidget(self.volumeSlider) self.playPauseBtn.setFocus() self.stopBtn.setVisible(False) # if not hide and later show -> paint update of player wont work properly! # status bar self.fpsLabel = QLabel("Frame #0") self.statusbar.addPermanentWidget(self.fpsLabel) # icons zoom_icon = QPixmap(":/icons/icons/zoom.png").scaled(QSize(16, 16), Qt.IgnoreAspectRatio, Qt.SmoothTransformation) self.zoomLbl.setPixmap(zoom_icon) db_icon = QPixmap(":/icons/icons/database.png").scaled(QSize(16, 16), Qt.IgnoreAspectRatio, Qt.SmoothTransformation) self.db_status = QLabel() self.db_status.setPixmap(db_icon) self.db_status.setMinimumWidth(25) self.db_status.setAlignment(Qt.AlignCenter) self.statusbar.addPermanentWidget(self.db_status)
def newwindows(self): import glob self.setWindowTitle('Media') action = QAction('text', self) self.actions = action.setStatusTip('check') self.setGeometry(100, 50, 1000, 1000) self.tool = QMenuBar(self) self.okay = self.tool.addMenu('okay') self.okay2 = self.tool.addMenu('okay') self.okay.addAction(action) self.setWindowIcon( QIcon('C:/Users/fish/Downloads/nice/icons8-sunday-50.png')) #'''''''\ #self.layout = QVBoxLayout(self) #self.browser = QWebView(self) '''damnit = "http://www.google.com/" self.f***s = self.browser.load(QUrl(damnit)) self.browser.move(500,100) self.browser.resize(500,500)''' dir = '' self.btnss = QPushButton('open file', self) self.btns2 = QPushButton('pause', self) self.btns3 = QPushButton('play', self) self.btns3.clicked.connect(self.played) self.btns2.clicked.connect(self.paused) self.btnss.move(100, 350) self.btns2.move(100, 400) self.btns3.move(100, 450) self.btnss.clicked.connect(self.fhile) path = self.filename print(self.filename) self.media = Phonon.MediaObject(self) self.video = Phonon.VideoWidget(self) self.video.setMinimumSize(400, 400) self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self) Phonon.createPath(self.media, self.audio) Phonon.createPath(self.media, self.video) self.media.setCurrentSource(Phonon.MediaSource(path)) self.media.play() self.video.show() # ------------------------------------------- self.btns4 = QPushButton('Full Screen', self) self.btns4.move(400, 0) self.btns4.clicked.connect(self.enlarged) # ------------------------------------------- # ------------------------------------------- self.slider = Phonon.VolumeSlider(self) self.slider.setAudioOutput(self.audio) self.slider.move(250, 50) self.slider.resize(250, 50) self.seekk = Phonon.SeekSlider(self) self.seekk.setMediaObject(self.media) self.seekk.move(200, 550) self.seekk.resize(350, 150) self.video.move(200, 200) # ------------------------------------------- #self.view = QListView(self) #self.view.move(600,100) #self.view.resize(100,100) lists = glob.glob('C:/Users/fish/Downloads/*.WMV') + glob.glob( 'C:/Users/fish/Downloads/*.mp4') + glob.glob( 'C:/Users/fish/Downloads/*.flv') self.newview = QListWidget(self) self.newview.resize(300, 300) self.newview.move(600, 300) for item in lists: self.okay = QListWidgetItem('okay') self.okay.setData(Qt.UserRole, str(item)) self.newview.addItem(self.okay) #self.newview.setValue(item) # ------------------------------------------- self.newview.clicked.connect(self.listfunc) #self.smodel = QStandardItemModel(self) # ------------------------------------------- #self.setKey(QShortcut(Qt.Key_Escape, self)) # self.act.setKey(QKeySequence('Alt+Enter')) #self.act.activated.connect(self.efullscreen) print(lists) #self.line = QTextEdit(self) #self.line.resize(25,25) #self.line.resize(25,25) #self.line.move(100,100) #self.line = QLineEdit(self) #self.line.resize(300,30) #self.line.move(600,70) # ------------------------------------------- self.naved = QPushButton('browser', self) self.naved.clicked.connect(self.nav) # ------------------------------------------- self.btned = QPushButton('Random Photo', self) self.btned.move(100, 300) self.btned.clicked.connect(self.check) # ------------------------------------------- self.show() print(path) if path == None: self.lab = QLabel(self) paths = 'C:/Users/fish/Desktop/pexels-photo.jpg' self.img = QPixmap(paths) self.lab.setPixmap(paths) self.lab.move(200, 175) self.lab.resize(400, 400) self.lab.show() else: paths = '' self.lab.resize(10, 10) self.lab.move(10, 10)