Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Player #149

Merged
merged 39 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0603413
Basic Video Player
DrRetro2033 Apr 30, 2024
d564354
Fixes and Comments
DrRetro2033 May 1, 2024
f7c7f9d
Fixed Bug Where Video's Audio did not stop when switching to a Image.
DrRetro2033 May 1, 2024
f0994f9
Merge branch 'main' of github.com:DrRetro2033/TagStudio
DrRetro2033 May 8, 2024
7349106
Redo on VideoPlayer. Now with rounded corners.
DrRetro2033 May 9, 2024
d576c8d
Merge branch 'TagStudioDev:main' into VideoPlayer
DrRetro2033 May 9, 2024
f1ad34f
Fixed size not being correct when first starting video player.
DrRetro2033 May 9, 2024
eadbbe6
Merge branch 'VideoPlayer' of github.com:DrRetro2033/TagStudio into V…
DrRetro2033 May 9, 2024
a2283a9
Ruff Check Fix
DrRetro2033 May 9, 2024
8e13bb7
Fixed Sizing Issue, and added Autoplay option in right click menu.
DrRetro2033 May 9, 2024
b995470
Autoplay Toggle and Fixed Issue with video not stoping after closing …
DrRetro2033 May 9, 2024
c3c64fb
Ruff Format
DrRetro2033 May 9, 2024
3ecc065
Suggested Changes Done
DrRetro2033 May 9, 2024
ec0d4cb
Commented out useless code that cause first warning.
DrRetro2033 May 9, 2024
0a75c62
Fixed Album Art Error
DrRetro2033 May 10, 2024
bdf44d9
Might have found solution to Autoplay Inconsistency
DrRetro2033 May 10, 2024
9be6022
Ruff Format
DrRetro2033 May 10, 2024
c523bd3
Finally Fixed Autoplay Inconsistency
DrRetro2033 May 10, 2024
2fe9a37
Merge branch 'main' of github.com:DrRetro2033/TagStudio
DrRetro2033 May 16, 2024
a4fe960
Merge branch 'main' of github.com:DrRetro2033/TagStudio into VideoPlayer
DrRetro2033 May 16, 2024
a8ddc5b
Fixed Merge Conficts
DrRetro2033 May 16, 2024
ae85c0c
Requested Changes and Ruff Format
DrRetro2033 May 16, 2024
6046efe
Test for new check
DrRetro2033 May 16, 2024
ed056c8
Fix for PySide App Test
DrRetro2033 May 16, 2024
018649e
More typing fixes and a few other changes.
DrRetro2033 May 17, 2024
4e90b80
Ruff Format
DrRetro2033 May 17, 2024
1df2582
MyPy Fix
DrRetro2033 May 17, 2024
5128bf5
MyPy Fix
DrRetro2033 May 17, 2024
16b0ec9
Ruff Format
DrRetro2033 May 17, 2024
d70cbae
MyPy Fix
DrRetro2033 May 17, 2024
d69e46e
MyPy and Ruff Fix
DrRetro2033 May 17, 2024
70e48d0
Code Clean-Up and Requests completed.
DrRetro2033 May 20, 2024
c9fa157
Merge branch 'TagStudioDev:main' into main
DrRetro2033 May 20, 2024
8d37d4f
Merge branch 'main' of github.com:DrRetro2033/TagStudio into VideoPlayer
DrRetro2033 May 20, 2024
4a07e1f
Conflict Fixes
DrRetro2033 May 20, 2024
17196d9
MyPy Fix
DrRetro2033 May 20, 2024
cea3eb4
Merge branch 'TagStudioDev:main' into main
DrRetro2033 May 27, 2024
9fd68db
Merge branch 'main' of github.com:DrRetro2033/TagStudio into VideoPlayer
DrRetro2033 May 27, 2024
728e475
Confict Fix
DrRetro2033 May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions tagstudio/resources/pause.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tagstudio/resources/play.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tagstudio/resources/volume_muted.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tagstudio/resources/volume_unmuted.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 11 additions & 18 deletions tagstudio/src/qt/resources_rc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Resource object code (Python 3)
# Created by: object code
# Created by: The Resource Compiler for Qt version 6.6.3
# Created by: The Resource Compiler for Qt version 6.5.1
# WARNING! All changes made in this file will be lost!

from PySide6 import QtCore
Expand Down Expand Up @@ -16884,34 +16884,27 @@
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x08\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x01\x1a\x00\x00\x00\x00\x00\x01\x00\x03\xf2%\
\x00\x00\x01\x8a\xfb\xb4\xd6\xbe\
\x00\x00\x01\x8f\x10b\x06\xcd\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x8a\xd2\x87V\xef\
\x00\x00\x01\x8f\x10b\x06\xd2\
\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x01\x00\x03\xdf\x81\
\x00\x00\x01\x8a\xfb\xc6t\x9f\
\x00\x00\x01\x8f\x10b\x06\xca\
\x00\x00\x01N\x00\x00\x00\x00\x00\x01\x00\x04\x0c\x00\
\x00\x00\x01\x8a\xfb\xb4\xc1\x95\
\x00\x00\x01\x8f\x10b\x06\xc8\
\x00\x00\x00<\x00\x00\x00\x00\x00\x01\x00\x00\x0b\xa2\
\x00\x00\x01\x8a\xd2\x8f\xdf\xf1\
\x00\x00\x01\x8f\x10b\x06\xca\
\x00\x00\x00n\x00\x00\x00\x00\x00\x01\x00\x00\x1b\x91\
\x00\x00\x01\x8a\xfb\xc6\x86\xda\
\x00\x00\x01\x8f\x10b\x06\xce\
\x00\x00\x00\xcc\x00\x00\x00\x00\x00\x01\x00\x00I\xea\
\x00\x00\x01\x8e\xfd%\xc3\xc7\
\x00\x00\x01\x8f\x10b\x06\xcc\
\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x01\x00\x00>\x14\
\x00\x00\x01\x8a\xd2\x83?\x9d\
\x00\x00\x01\x8f\x10b\x06\xca\
"


def qInitResources():
QtCore.qRegisterResourceData(
0x03, qt_resource_struct, qt_resource_name, qt_resource_data
)

QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)

def qCleanupResources():
QtCore.qUnregisterResourceData(
0x03, qt_resource_struct, qt_resource_name, qt_resource_data
)

QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)

qInitResources()
32 changes: 29 additions & 3 deletions tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
EditTextLine,
ItemThumb,
)
from src.qt.widgets.video_player import VideoPlayer

# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -93,6 +94,8 @@ def __init__(self, library: Library, driver: "QtDriver"):
self.preview_img.setMinimumSize(*self.img_button_size)
self.preview_img.setFlat(True)
self.preview_img.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu)
self.preview_vid = VideoPlayer(driver)
self.preview_vid.hide()

self.preview_img.addAction(self.open_file_action)
self.preview_img.addAction(self.open_explorer_action)
Expand Down Expand Up @@ -124,7 +127,9 @@ def __init__(self, library: Library, driver: "QtDriver"):

image_layout.addWidget(self.preview_img)
image_layout.setAlignment(self.preview_img, Qt.AlignmentFlag.AlignCenter)

image_layout.addWidget(self.preview_vid)
image_layout.setAlignment(self.preview_vid, Qt.AlignmentFlag.AlignCenter)
self.image_container.setMinimumSize(*self.img_button_size)
self.file_label = FileOpenerLabel("Filename")
self.file_label.setWordWrap(True)
self.file_label.setTextInteractionFlags(
Expand Down Expand Up @@ -287,6 +292,9 @@ def update_image_size(self, size: tuple[int, int], ratio: float = None):
self.img_button_size = (adj_width, adj_height)
self.preview_img.setMaximumSize(adj_size)
self.preview_img.setIconSize(adj_size)
self.preview_vid.resizeVideo(adj_size)
self.preview_vid.setMaximumSize(adj_size)
self.preview_vid.setMinimumSize(adj_size)
# self.preview_img.setMinimumSize(adj_size)

# if self.preview_img.iconSize().toTuple()[0] < self.preview_img.size().toTuple()[0] + 10:
Expand Down Expand Up @@ -359,7 +367,9 @@ def update_widgets(self):
pass
for i, c in enumerate(self.containers):
c.setHidden(True)

self.preview_img.show()
self.preview_vid.stop()
self.preview_vid.hide()
self.selected = list(self.driver.selected)
self.add_field_button.setHidden(True)

Expand Down Expand Up @@ -390,7 +400,9 @@ def update_widgets(self):
self.open_explorer_action.triggered.connect(
self.opener.open_explorer
)

self.preview_img.show()
self.preview_vid.stop()
self.preview_vid.hide()
# TODO: Do this somewhere else, this is just here temporarily.
extension = os.path.splitext(filepath)[1][1:].lower()
try:
Expand All @@ -404,6 +416,7 @@ def update_widgets(self):
if image.mode != "RGB":
image = image.convert(mode="RGB")
elif extension in VIDEO_TYPES:
self.preview_img.hide()
video = cv2.VideoCapture(filepath)
video.set(
cv2.CAP_PROP_POS_FRAMES,
Expand All @@ -418,6 +431,16 @@ def update_widgets(self):
success, frame = video.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image = Image.fromarray(frame)
self.preview_vid.play(
filepath, QSize(image.width, image.height)
)
self.resizeEvent(
QResizeEvent(
QSize(image.width, image.height),
QSize(image.width, image.height),
)
)
self.preview_vid.show()

# Stats for specific file types are displayed here.
if extension in (IMAGE_TYPES + VIDEO_TYPES):
Expand Down Expand Up @@ -466,6 +489,9 @@ def update_widgets(self):

# Multiple Selected Items
elif len(self.driver.selected) > 1:
self.preview_img.show()
self.preview_vid.stop()
self.preview_vid.hide()
if self.selected != self.driver.selected:
self.file_label.setText(f"{len(self.driver.selected)} Items Selected")
self.file_label.setCursor(Qt.CursorShape.ArrowCursor)
Expand Down