-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.py
43 lines (32 loc) · 1.42 KB
/
animation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from PyQt5.QtWidgets import QApplication, QLineEdit, QPlainTextEdit, QRadioButton, QWidget, QHBoxLayout, QVBoxLayout, QTextEdit, QPushButton, QLabel, QFileDialog
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent
class My2DAnimationWidget(QWidget):
def __init__(self, file_path):
super().__init__()
layout = QVBoxLayout(self)
# Create a label to display the video
self.label = QLabel(self)
layout.addWidget(self.label)
# Create a media player object
self.media_player = QMediaPlayer(self)
self.media_player.setVideoOutput(self.label)
# Set the media player's media content
media_content = QMediaContent(QUrl.fromLocalFile(file_path))
self.media_player.setMedia(media_content)
# Play the video
self.media_player.play()
class My3DAnimationWidget(QWidget):
def __init__(self, file_path):
super().__init__()
layout = QVBoxLayout(self)
# Create a label to display the video
self.label = QLabel(self)
layout.addWidget(self.label)
# Create a media player object
self.media_player = QMediaPlayer(self)
self.media_player.setVideoOutput(self.label)
# Set the media player's media content
media_content = QMediaContent(QUrl.fromLocalFile(file_path))
self.media_player.setMedia(media_content)
# Play the video
self.media_player.play()