|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
|
|
|
|
from PyQt5.QtCore import QTimer
|
|
|
|
|
from PyQt5.QtMultimediaWidgets import QVideoWidget
|
|
|
|
|
from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer
|
|
|
|
|
from PyQt5.QtWidgets import QFileDialog
|
|
|
|
@ -71,6 +72,7 @@ class Ui_MainWindow1(object):
|
|
|
|
|
self.sld_duration.setGeometry(QtCore.QRect(20, 20, 1051, 22))
|
|
|
|
|
self.sld_duration.setOrientation(QtCore.Qt.Horizontal)
|
|
|
|
|
self.sld_duration.setObjectName("sld_duration")
|
|
|
|
|
self.sld_duration.setEnabled(True)
|
|
|
|
|
self.lab_duration = QtWidgets.QLabel(self.frame_2)
|
|
|
|
|
self.lab_duration.setGeometry(QtCore.QRect(1100, 20, 81, 21))
|
|
|
|
|
font = QtGui.QFont()
|
|
|
|
@ -111,12 +113,17 @@ class Ui_MainWindow1(object):
|
|
|
|
|
|
|
|
|
|
self.player = QMediaPlayer()
|
|
|
|
|
self.player.setVideoOutput(self.widget)
|
|
|
|
|
self.maxValue = 1000
|
|
|
|
|
self.timer = QTimer()
|
|
|
|
|
self.timer.start(1000)
|
|
|
|
|
self.timer.timeout.connect(lambda: self.onTimerOut())
|
|
|
|
|
self.actionl1.triggered.connect(lambda: self.openfile())
|
|
|
|
|
self.displayTime()
|
|
|
|
|
self.pushButton_2.clicked.connect(lambda: self.playpause())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def openfile(self):
|
|
|
|
|
self.player.setMedia(QMediaContent(QFileDialog.getOpenFileUrl()[0]))
|
|
|
|
|
media_list = QMediaContent(QFileDialog.getOpenFileUrl()[0])
|
|
|
|
|
self.player.setMedia(media_list)
|
|
|
|
|
self.player.play()
|
|
|
|
|
self.player.pause()
|
|
|
|
|
|
|
|
|
@ -133,16 +140,17 @@ class Ui_MainWindow1(object):
|
|
|
|
|
icon9.addPixmap(QtGui.QPixmap("window_png/暂停.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
|
|
|
self.pushButton_2.setIcon(icon9)
|
|
|
|
|
self.pushButton_2.setIconSize(QtCore.QSize(50, 50))
|
|
|
|
|
def getms(self):
|
|
|
|
|
a = self.player.duration()
|
|
|
|
|
self.sld_duration.setRange(0, a)
|
|
|
|
|
self.sld_duration.setEnabled(True)
|
|
|
|
|
return a
|
|
|
|
|
def displayTime(self):
|
|
|
|
|
ms = self.getms()
|
|
|
|
|
|
|
|
|
|
def onTimerOut(self):
|
|
|
|
|
alltime = self.player.duration()
|
|
|
|
|
ms = self.player.position()
|
|
|
|
|
minutes = int(ms / 60000)
|
|
|
|
|
seconds = int((ms - minutes * 60000) / 1000)
|
|
|
|
|
self.lab_duration.setText('{}:{}'.format(minutes, seconds))
|
|
|
|
|
minute = int(alltime / 60000)
|
|
|
|
|
sec = int((alltime - minute * 60000) / 1000)
|
|
|
|
|
self.lab_duration.setText('{}:{}/{}:{}'.format(minutes, seconds, minute, sec))
|
|
|
|
|
self.sld_duration.setMaximum(alltime)
|
|
|
|
|
self.sld_duration.setValue(ms)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def retranslateUi(self, MainWindow):
|
|
|
|
|