-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvideoPlayerApp.py
34 lines (25 loc) · 1.04 KB
/
videoPlayerApp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from PyQt4 import QtGui
from PyQt4 import phonon
from ui import main
class VideoPlayerClass(main.Ui_MainWindow, QtGui.QMainWindow):
def __init__(self):
super(VideoPlayerClass, self).__init__()
self.setupUi(self)
self.play_PB.clicked.connect(lambda: self.videoPlayer.play())
self.pause_PB.clicked.connect(lambda: self.videoPlayer.pause())
self.stop_PB.clicked.connect(lambda: self.videoPlayer.stop())
self.actionOpen.triggered.connect(self.select_video)
def select_video(self):
filepath = QtGui.QFileDialog.getOpenFileName(self, 'Select Video')
self.load_video(filepath)
def load_video(self, filepath):
media = phonon.Phonon.MediaSource(filepath)
self.videoPlayer.load(media)
self.seekSlider.setMediaObject(self.videoPlayer.mediaObject())
self.volumeSlider.setAudioOutput(self.videoPlayer.audioOutput())
self.videoPlayer.play()
if __name__ == '__main__':
app = QtGui.QApplication([])
vp = VideoPlayerClass()
vp.show()
app.exec_()