Skip to content

Commit 5db3ee5

Browse files
Update Video Player for V1.1
Added UI text translating action.
1 parent c5cd2f3 commit 5db3ee5

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

network_video_player.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
QTextEdit,
3131
QProgressDialog,
3232
)
33-
from PySide6.QtCore import Qt, QThread, Signal, QMutex
33+
from PySide6.QtCore import Qt, QThread, Signal, QMutex, QCoreApplication
3434
from PySide6.QtGui import QImage, QPixmap, QPainter, QColor
3535

3636

@@ -861,16 +861,18 @@ def init_ui(self):
861861
widget.hide()
862862

863863
# 控制按钮和设备选择
864-
self.play_btn = QPushButton("Play")
864+
self.play_btn = QPushButton(QCoreApplication.translate("Dialog", "Play"))
865865
self.play_btn.clicked.connect(self.toggle_play)
866-
self.stop_btn = QPushButton("Stop")
866+
self.stop_btn = QPushButton(QCoreApplication.translate("Dialog", "Stop"))
867867
self.stop_btn.clicked.connect(self.stop)
868868

869-
self.device_label = QLabel("音频设备:")
869+
self.device_label = QLabel(
870+
QCoreApplication.translate("Dialog", "Audio Device:")
871+
)
870872
self.device_combo = QComboBox()
871873
self.device_combo.currentIndexChanged.connect(self.on_device_changed)
872874

873-
self.volume_label = QLabel("音量:")
875+
self.volume_label = QLabel(QCoreApplication.translate("Dialog", "Volume:"))
874876
self.volume_slider = QSlider(Qt.Horizontal)
875877
self.volume_slider.setRange(0, 100)
876878
self.volume_slider.setValue(100)
@@ -1082,7 +1084,7 @@ def _on_audio_ready_after_reload(self, audio_spec, target_pos_ms):
10821084
if self.video_loaded:
10831085
self.set_play_position(target_pos_ms)
10841086
self.is_playing = True
1085-
self.play_btn.setText("Pause")
1087+
self.play_btn.setText(QCoreApplication.translate("Dialog", "Pause"))
10861088

10871089
# 开始播放
10881090
if self.video_thread:
@@ -1252,15 +1254,15 @@ def toggle_play(self):
12521254

12531255
if self.audio_thread and self.audio_thread.paused:
12541256
self.audio_thread.pause()
1255-
self.play_btn.setText("Pause")
1257+
self.play_btn.setText(QCoreApplication.translate("Dialog", "Pause"))
12561258
self.log("开始播放")
12571259
else:
12581260
if not self.video_thread.paused:
12591261
self.video_thread.pause()
12601262

12611263
if self.audio_thread and not self.audio_thread.paused:
12621264
self.audio_thread.pause()
1263-
self.play_btn.setText("Play")
1265+
self.play_btn.setText(QCoreApplication.translate("Dialog", "Play"))
12641266
self.log("已暂停")
12651267

12661268
def stop(self):
@@ -1306,6 +1308,7 @@ def handle_ffmpeg_error(self, msg):
13061308
self.log(f"FFmpeg: {msg}")
13071309

13081310
def closeEvent(self, event):
1311+
self.video_thread._is_to_stop_old_frameTimer = True
13091312
self.stop()
13101313
event.accept()
13111314

0 commit comments

Comments
 (0)