|
1 | 1 | import os |
2 | 2 | from PyQt6.QtWidgets import QMessageBox, QFileDialog |
3 | | -from PyQt6.QtCore import Qt, QModelIndex |
| 3 | +from PyQt6.QtCore import Qt, QModelIndex, QTimer |
| 4 | +# [Ref] Import from the correct models location |
4 | 5 | from models.project_tree import ProjectTreeModel |
5 | 6 | from utils import SUPPORTED_EXTENSIONS |
6 | 7 |
|
@@ -87,11 +88,19 @@ def on_item_selected(self, current, previous): |
87 | 88 | self.main.annot_manager.display_manual_annotation(path) |
88 | 89 | self.ui.classification_ui.right_panel.manual_box.setEnabled(True) |
89 | 90 |
|
90 | | - # Update Center Panel (Video) |
| 91 | + # [FIX] Get player instance |
| 92 | + player = self.ui.classification_ui.center_panel.single_view_widget.player |
| 93 | + |
| 94 | + # [FIX] Explicitly stop the player before loading a new source. |
| 95 | + # This helps reset the video pipeline and prevents black screens on some systems. |
| 96 | + player.stop() |
| 97 | + |
| 98 | + # Update Center Panel (Video) - This loads the new source |
91 | 99 | self.ui.classification_ui.center_panel.show_single_view(path) |
92 | 100 |
|
93 | | - # Force play when switching clips |
94 | | - self.ui.classification_ui.center_panel.single_view_widget.player.play() |
| 101 | + # [FIX] Force play with increased delay (150ms). |
| 102 | + # 150ms-200ms is a safer buffer for PyQt6 QMediaPlayer. |
| 103 | + QTimer.singleShot(150, player.play) |
95 | 104 |
|
96 | 105 | def play_video(self): |
97 | 106 | """Toggle Play/Pause""" |
@@ -153,7 +162,7 @@ def _nav_tree(self, step, level): |
153 | 162 |
|
154 | 163 | new_row = curr.row() + step |
155 | 164 |
|
156 | | - # Simple bounds check |
| 165 | + # Simple bounds check, logic can be improved to skip hidden items |
157 | 166 | if 0 <= new_row < model.rowCount(QModelIndex()): |
158 | 167 | # Check visibility (filter) |
159 | 168 | while 0 <= new_row < model.rowCount(QModelIndex()): |
|
0 commit comments