问题交流、反馈请到 https://github.com/moneypi/pyqt5_mediaplayer
首先肯定要安装pyqt5,顺便也安装一下opencv
pip install PyQt5
pip install opencv-python
Windows下需要安装Lavfilter解码器 https://github.com/Nevcairiel/LAVFilters/releases
Ubuntu下需要安装 gstreamer1.0-plugins-ugly
sudo apt install gstreamer1.0-plugins-ugly -y
包括左右键快进,进度条拖动,上下键调节音量等基础功能
import os
import time
import sys
import cv2
FileName = os.path.basename(sys.argv[0])
FilePath = sys.argv[0].replace(FileName, "")
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtMultimedia import *
from PyQt5.QtMultimediaWidgets import *
class TestSlider(QSlider):
def __init__(self, *__args):
super(TestSlider, self).__init__(*__args)
def keyPressEvent(self, event):
QCoreApplication.sendEvent(self.parentWidget(), event)
class m_window(QWidget):
def __init__(self):
super(m_window, self).__init__()
self.media_path = ""
self.timeLabelWidth = 120
self.shape = (360, 480)
self.volume = 50
self.Slider = TestSlider(Qt.Horizontal, self)
self.ProgressBarInit()
self.mplayer = QMediaPlayer(self)
self.m