keyboard shortcuts
This commit is contained in:
parent
54a8cd9b4f
commit
9c4050240b
1 changed files with 31 additions and 25 deletions
|
@ -6,7 +6,6 @@ from PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput
|
|||
from PyQt6.QtMultimediaWidgets import QVideoWidget
|
||||
from PyQt6.QtCore import QUrl, Qt, QEvent
|
||||
|
||||
|
||||
class VideoPlayer(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
@ -21,16 +20,12 @@ class VideoPlayer(QMainWindow):
|
|||
self.video_widget = QVideoWidget()
|
||||
self.installEventFilter(self)
|
||||
|
||||
self.start_button = QPushButton("Start")
|
||||
self.start_button.setFixedSize(60, 33)
|
||||
self.start_button = QPushButton("▷||")
|
||||
self.start_button.setFixedSize(33, 33)
|
||||
self.start_button.clicked.connect(self.start_video)
|
||||
|
||||
self.pause_button = QPushButton("Pause")
|
||||
self.pause_button.setFixedSize(60, 33)
|
||||
self.pause_button.clicked.connect(self.pause_video)
|
||||
|
||||
self.stop_button = QPushButton("Stop")
|
||||
self.stop_button.setFixedSize(60, 33)
|
||||
self.stop_button = QPushButton("□")
|
||||
self.stop_button.setFixedSize(33, 33)
|
||||
self.stop_button.clicked.connect(self.stop_video)
|
||||
|
||||
self.slider = QSlider(Qt.Orientation.Horizontal)
|
||||
|
@ -47,11 +42,11 @@ class VideoPlayer(QMainWindow):
|
|||
layout = QVBoxLayout()
|
||||
controls = QHBoxLayout()
|
||||
controls.addWidget(self.start_button)
|
||||
controls.addWidget(self.pause_button)
|
||||
controls.addWidget(self.stop_button)
|
||||
controls.addWidget(self.slider)
|
||||
layout.addWidget(self.video_widget)
|
||||
layout.addLayout(controls)
|
||||
layout.addWidget(self.slider)
|
||||
#layout.addWidget(self.slider)
|
||||
|
||||
container = QWidget()
|
||||
container.setLayout(layout)
|
||||
|
@ -60,13 +55,10 @@ class VideoPlayer(QMainWindow):
|
|||
|
||||
def set_layout(self):
|
||||
self.video_widget = QVideoWidget()
|
||||
self.start_button = QPushButton("Start")
|
||||
self.start_button = QPushButton("▷||")
|
||||
self.start_button.setFixedSize(60, 33)
|
||||
self.start_button.clicked.connect(self.start_video)
|
||||
self.pause_button = QPushButton("Pause")
|
||||
self.pause_button.setFixedSize(60, 33)
|
||||
self.pause_button.clicked.connect(self.pause_video)
|
||||
self.stop_button = QPushButton("Stop")
|
||||
self.stop_button = QPushButton("□")
|
||||
self.stop_button.setFixedSize(60, 33)
|
||||
self.stop_button.clicked.connect(self.stop_video)
|
||||
self.slider = QSlider(Qt.Orientation.Horizontal)
|
||||
|
@ -75,21 +67,23 @@ class VideoPlayer(QMainWindow):
|
|||
layout = QVBoxLayout()
|
||||
controls = QHBoxLayout()
|
||||
controls.addWidget(self.start_button)
|
||||
controls.addWidget(self.pause_button)
|
||||
controls.addWidget(self.stop_button)
|
||||
controls.addWidget(self.slider)
|
||||
layout.addWidget(self.video_widget)
|
||||
layout.addLayout(controls)
|
||||
layout.addWidget(self.slider)
|
||||
#layout.addWidget(self.slider)
|
||||
|
||||
container = QWidget()
|
||||
container.setLayout(layout)
|
||||
self.setCentralWidget(container)
|
||||
|
||||
def start_video(self):
|
||||
self.media_player.play()
|
||||
|
||||
def pause_video(self):
|
||||
self.media_player.pause()
|
||||
if self.media_player.isPlaying():
|
||||
self.media_player.pause()
|
||||
#self.start_button.setText("Play")
|
||||
else:
|
||||
self.media_player.play()
|
||||
#self.start_button.setText("Pause")
|
||||
|
||||
def stop_video(self):
|
||||
self.media_player.stop()
|
||||
|
@ -116,17 +110,17 @@ class VideoPlayer(QMainWindow):
|
|||
else:
|
||||
if self.isMaximized():
|
||||
self.fswindow = 1
|
||||
print("maximized")
|
||||
#print("maximized")
|
||||
else:
|
||||
self.fswindow = 2
|
||||
self.showFullScreen()
|
||||
self.setCentralWidget(self.video_widget)
|
||||
def dclickthr(self):
|
||||
self.dclick = True
|
||||
print(self.dclick)
|
||||
#print(self.dclick)
|
||||
time.sleep(0.5)
|
||||
self.dclick = False
|
||||
print(self.dclick)
|
||||
#print(self.dclick)
|
||||
|
||||
def eventFilter(self, obj, event):
|
||||
|
||||
|
@ -137,6 +131,18 @@ class VideoPlayer(QMainWindow):
|
|||
dclickth = threading.Thread(target=self.dclickthr, name="Double Click")
|
||||
dclickth.start()
|
||||
#print(event.type())
|
||||
elif event.type() == QEvent.Type.KeyPress:
|
||||
if event.key() == 83:
|
||||
self.media_player.stop()
|
||||
elif event.key() == 68:
|
||||
self.media_player.setPosition(self.media_player.position()+5000)
|
||||
elif event.key() == 65:
|
||||
self.media_player.setPosition(self.media_player.position()-5000)
|
||||
elif event.key() == 87:
|
||||
self.start_video()
|
||||
elif event.key() == 70:
|
||||
self.toglefs()
|
||||
#print(event.key())
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in a new issue