adding in video playing successfully
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
env
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import sys
|
||||||
|
import random
|
||||||
|
from PySide6 import QtCore, QtWidgets, QtGui
|
||||||
|
|
||||||
|
class MyWidget(QtWidgets.QWidget):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
|
||||||
|
|
||||||
|
self.button = QtWidgets.QPushButton("Click me!")
|
||||||
|
self.text = QtWidgets.QLabel("Hello World",
|
||||||
|
alignment=QtCore.Qt.AlignCenter)
|
||||||
|
|
||||||
|
self.layout = QtWidgets.QVBoxLayout(self)
|
||||||
|
self.layout.addWidget(self.text)
|
||||||
|
self.layout.addWidget(self.button)
|
||||||
|
|
||||||
|
self.button.clicked.connect(self.magic)
|
||||||
|
|
||||||
|
@QtCore.Slot()
|
||||||
|
def magic(self):
|
||||||
|
self.text.setText(random.choice(self.hello))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QtWidgets.QApplication([])
|
||||||
|
|
||||||
|
widget = MyWidget()
|
||||||
|
widget.resize(800, 600)
|
||||||
|
widget.show()
|
||||||
|
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import sys
|
||||||
|
import random
|
||||||
|
from PySide6 import QtCore, QtWidgets, QtGui, QtMultimedia, QtMultimediaWidgets
|
||||||
|
|
||||||
|
class MyWidget(QtWidgets.QWidget):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
|
||||||
|
|
||||||
|
self.button = QtWidgets.QPushButton("Click me!")
|
||||||
|
self.text = QtWidgets.QLabel("Hello World",
|
||||||
|
alignment=QtCore.Qt.AlignCenter)
|
||||||
|
|
||||||
|
self.player = QtMultimedia.QMediaPlayer()
|
||||||
|
self.player.setSource(QtCore.QUrl("http://techslides.com/demos/sample-videos/small.mp4"))
|
||||||
|
videoWidget = QtMultimediaWidgets.QVideoWidget()
|
||||||
|
self.player.setVideoOutput(videoWidget)
|
||||||
|
videoWidget.show()
|
||||||
|
self.player.play()
|
||||||
|
|
||||||
|
self.layout = QtWidgets.QVBoxLayout(self)
|
||||||
|
self.layout.addWidget(self.text)
|
||||||
|
self.layout.addWidget(self.button)
|
||||||
|
self.layout.addWidget(videoWidget)
|
||||||
|
|
||||||
|
self.button.clicked.connect(self.magic)
|
||||||
|
|
||||||
|
@QtCore.Slot()
|
||||||
|
def magic(self):
|
||||||
|
self.text.setText(random.choice(self.hello))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QtWidgets.QApplication([])
|
||||||
|
|
||||||
|
widget = MyWidget()
|
||||||
|
widget.resize(800, 600)
|
||||||
|
widget.show()
|
||||||
|
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user