This commit is contained in:
Page Asgardius 2024-08-17 13:16:12 -07:00
parent 1d635a18d1
commit 939035a5c7
2 changed files with 80 additions and 1 deletions

View file

@ -1,3 +1,4 @@
# s3manager-qt
Amazon S3 file manager for GNU/Linux. Made with pyqt6
This is currently a proof of concept

78
videoplayer.py Normal file
View file

@ -0,0 +1,78 @@
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow, QHBoxLayout, QVBoxLayout, QWidget, QPushButton, QSlider
from PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput
from PyQt6.QtMultimediaWidgets import QVideoWidget
from PyQt6.QtCore import QUrl, Qt
class VideoPlayer(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Video Player")
self.setGeometry(100, 100, 640, 480)
#self.showFullScreen()
self.media_player = QMediaPlayer(None)
self.video_widget = QVideoWidget()
self.start_button = QPushButton("Start")
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.setFixedSize(60, 33)
self.stop_button.clicked.connect(self.stop_video)
self.slider = QSlider(Qt.Orientation.Horizontal)
self.slider.sliderMoved.connect(self.set_position)
self.media_player.setVideoOutput(self.video_widget)
self.media_player.setSource(QUrl("https://video.asgardius.company/static/streaming-playlists/hls/41bf7df4-8f6c-45e9-96ef-a8dd57c865c8/4cd1430a-0124-473f-98ce-2f65a9bafad9-480.m3u8"))
self.media_player.positionChanged.connect(self.position_changed)
self.media_player.durationChanged.connect(self.duration_changed)
self.audio_output = QAudioOutput()
self.audio_output.setVolume(100)
self.media_player.setAudioOutput(self.audio_output)
layout = QVBoxLayout()
controls = QHBoxLayout()
controls.addWidget(self.start_button)
controls.addWidget(self.pause_button)
controls.addWidget(self.stop_button)
layout.addWidget(self.video_widget)
layout.addLayout(controls)
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()
def stop_video(self):
self.media_player.stop()
def set_position(self, position):
self.media_player.setPosition(position)
def position_changed(self, position):
self.slider.setValue(position)
def duration_changed(self, duration):
self.slider.setRange(0, duration)
if __name__ == "__main__":
app = QApplication(sys.argv)
video_player = VideoPlayer()
video_player.show()
sys.exit(app.exec())