Skip to content

Commit 9f630fe

Browse files
authored
Video Player (#149)
* Basic Video Player * Fixes and Comments * Fixed Bug Where Video's Audio did not stop when switching to a Image. * Redo on VideoPlayer. Now with rounded corners. * Fixed size not being correct when first starting video player. * Ruff Check Fix * Fixed Sizing Issue, and added Autoplay option in right click menu. * Autoplay Toggle and Fixed Issue with video not stoping after closing library. * Ruff Format * Suggested Changes Done * Commented out useless code that cause first warning. * Fixed Album Art Error * Might have found solution to Autoplay Inconsistency * Ruff Format * Finally Fixed Autoplay Inconsistency * Fixed Merge Conficts * Requested Changes and Ruff Format * Test for new check * Fix for PySide App Test * More typing fixes and a few other changes. * Ruff Format * MyPy Fix * MyPy Fix * Ruff Format * MyPy Fix * MyPy and Ruff Fix * Code Clean-Up and Requests completed. * Conflict Fixes * MyPy Fix * Confict Fix It appears one of the commits from main fixed the autoplay issue.
1 parent 6798ffd commit 9f630fe

File tree

9 files changed

+416
-10
lines changed

9 files changed

+416
-10
lines changed

.github/workflows/apprun.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ jobs:
3232
libxcb-render-util0 \
3333
libxcb-xinerama0 \
3434
libopengl0 \
35-
libxcb-cursor0
35+
libxcb-cursor0 \
36+
libpulse0
3637
3738
- name: Install dependencies
3839
run: |

tagstudio/resources/pause.svg

Lines changed: 1 addition & 0 deletions
Loading

tagstudio/resources/play.svg

Lines changed: 1 addition & 0 deletions
Loading

tagstudio/resources/volume_muted.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

tagstudio/src/core/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class SettingItems(str, enum.Enum):
88
LAST_LIBRARY = "last_library"
99
LIBS_LIST = "libs_list"
1010
WINDOW_SHOW_LIBS = "window_show_libs"
11+
AUTOPLAY = "autoplay_videos"
1112

1213

1314
class Theme(str, enum.Enum):

tagstudio/src/qt/resources_rc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Resource object code (Python 3)
22
# Created by: object code
3-
# Created by: The Resource Compiler for Qt version 6.6.3
3+
# Created by: The Resource Compiler for Qt version 6.5.1
44
# WARNING! All changes made in this file will be lost!
55

66
from PySide6 import QtCore
@@ -16232,15 +16232,15 @@
1623216232
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x05\x00\x00\x00\x02\
1623316233
\x00\x00\x00\x00\x00\x00\x00\x00\
1623416234
\x00\x00\x00\x96\x00\x00\x00\x00\x00\x01\x00\x03\xca\xbe\
16235-
\x00\x00\x01\x8a\xfb\xb4\xd6\xbe\
16235+
\x00\x00\x01\x8f\x10b\x06\xcd\
1623616236
\x00\x00\x00b\x00\x00\x00\x00\x00\x01\x00\x03\xb8\x1a\
16237-
\x00\x00\x01\x8a\xfb\xc6t\x9f\
16237+
\x00\x00\x01\x8f\x10b\x06\xca\
1623816238
\x00\x00\x00\xca\x00\x00\x00\x00\x00\x01\x00\x03\xe4\x99\
16239-
\x00\x00\x01\x8a\xfb\xb4\xc1\x95\
16239+
\x00\x00\x01\x8f\x10b\x06\xc8\
1624016240
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
16241-
\x00\x00\x01\x8a\xfb\xc6\x86\xda\
16241+
\x00\x00\x01\x8f\x10b\x06\xce\
1624216242
\x00\x00\x00H\x00\x00\x00\x00\x00\x01\x00\x00\x22\x83\
16243-
\x00\x00\x01\x8e\xfd%\xc3\xc7\
16243+
\x00\x00\x01\x8f\x10b\x06\xcc\
1624416244
"
1624516245

1624616246
def qInitResources():

tagstudio/src/qt/widgets/preview_panel.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from src.qt.widgets.text_box_edit import EditTextBox
4242
from src.qt.widgets.text_line_edit import EditTextLine
4343
from src.qt.widgets.item_thumb import ItemThumb
44+
from src.qt.widgets.video_player import VideoPlayer
4445

4546

4647
# Only import for type checking/autocompletion, will not be imported at runtime.
@@ -90,7 +91,8 @@ def __init__(self, library: Library, driver: "QtDriver"):
9091

9192
self.preview_img.addAction(self.open_file_action)
9293
self.preview_img.addAction(self.open_explorer_action)
93-
94+
self.preview_vid = VideoPlayer(driver)
95+
self.preview_vid.hide()
9496
self.thumb_renderer = ThumbRenderer()
9597
self.thumb_renderer.updated.connect(
9698
lambda ts, i, s: (self.preview_img.setIcon(i))
@@ -110,7 +112,9 @@ def __init__(self, library: Library, driver: "QtDriver"):
110112

111113
image_layout.addWidget(self.preview_img)
112114
image_layout.setAlignment(self.preview_img, Qt.AlignmentFlag.AlignCenter)
113-
115+
image_layout.addWidget(self.preview_vid)
116+
image_layout.setAlignment(self.preview_vid, Qt.AlignmentFlag.AlignCenter)
117+
self.image_container.setMinimumSize(*self.img_button_size)
114118
self.file_label = FileOpenerLabel("Filename")
115119
self.file_label.setWordWrap(True)
116120
self.file_label.setTextInteractionFlags(
@@ -378,6 +382,9 @@ def update_image_size(self, size: tuple[int, int], ratio: float = None):
378382
self.img_button_size = (int(adj_width), int(adj_height))
379383
self.preview_img.setMaximumSize(adj_size)
380384
self.preview_img.setIconSize(adj_size)
385+
self.preview_vid.resizeVideo(adj_size)
386+
self.preview_vid.setMaximumSize(adj_size)
387+
self.preview_vid.setMinimumSize(adj_size)
381388
# self.preview_img.setMinimumSize(adj_size)
382389

383390
# if self.preview_img.iconSize().toTuple()[0] < self.preview_img.size().toTuple()[0] + 10:
@@ -460,14 +467,19 @@ def update_widgets(self):
460467
pass
461468
for i, c in enumerate(self.containers):
462469
c.setHidden(True)
463-
470+
self.preview_img.show()
471+
self.preview_vid.stop()
472+
self.preview_vid.hide()
464473
self.selected = list(self.driver.selected)
465474
self.add_field_button.setHidden(True)
466475

467476
# 1 Selected Item
468477
elif len(self.driver.selected) == 1:
469478
# 1 Selected Entry
470479
if self.driver.selected[0][0] == ItemType.ENTRY:
480+
self.preview_img.show()
481+
self.preview_vid.stop()
482+
self.preview_vid.hide()
471483
item: Entry = self.lib.get_entry(self.driver.selected[0][1])
472484
# If a new selection is made, update the thumbnail and filepath.
473485
if not self.selected or self.selected != self.driver.selected:
@@ -513,6 +525,18 @@ def update_widgets(self):
513525
success, frame = video.read()
514526
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
515527
image = Image.fromarray(frame)
528+
if success:
529+
self.preview_img.hide()
530+
self.preview_vid.play(
531+
filepath, QSize(image.width, image.height)
532+
)
533+
self.resizeEvent(
534+
QResizeEvent(
535+
QSize(image.width, image.height),
536+
QSize(image.width, image.height),
537+
)
538+
)
539+
self.preview_vid.show()
516540

517541
# Stats for specific file types are displayed here.
518542
if filepath.suffix.lower() in (
@@ -579,6 +603,9 @@ def update_widgets(self):
579603

580604
# Multiple Selected Items
581605
elif len(self.driver.selected) > 1:
606+
self.preview_img.show()
607+
self.preview_vid.stop()
608+
self.preview_vid.hide()
582609
if self.selected != self.driver.selected:
583610
self.file_label.setText(f"{len(self.driver.selected)} Items Selected")
584611
self.file_label.setCursor(Qt.CursorShape.ArrowCursor)

0 commit comments

Comments
 (0)