进度条和视频计时功能的实现

pull/26/head
lvs 3 years ago
parent 5af38dc645
commit 27a9bfb88c

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (pythonproject)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/qt.iml" filepath="$PROJECT_DIR$/.idea/qt.iml" />
</modules>
</component>
</project>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9 (pythonproject)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

@ -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):

Loading…
Cancel
Save