Skip to content

Commit

Permalink
feat: add command to sync other videos by active
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Jun 22, 2022
1 parent 2d040da commit 90a0449
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
16 changes: 14 additions & 2 deletions gridplayer/player/managers/actions.py
Expand Up @@ -280,6 +280,18 @@
"check_if": ("is_active_param_set_to", "aspect_mode", VideoAspect.NONE),
"show_if": "is_active_initialized",
},
"Seek Others (Percent)": {
"title": translate("Actions", "Sync By Percent"),
"icon": "seek-sync-percent",
"func": ("active", "sync_others_percent"),
"show_if": "is_active_seekable",
},
"Seek Others (Timecode)": {
"title": translate("Actions", "Sync By Timecode"),
"icon": "seek-sync-time",
"func": ("active", "sync_others_time"),
"show_if": "is_active_seekable",
},
"Stream Quality": {
"title": translate("Actions", "Stream Quality"),
"icon": "stream-quality",
Expand Down Expand Up @@ -558,13 +570,13 @@
"check_if": ("is_seek_sync_mode_set_to", SeekSyncMode.DISABLED),
},
"Seek Sync (Percent)": {
"title": translate("Actions", "Sync by percent"),
"title": translate("Actions", "Sync By Percent"),
"icon": "seek-sync-percent",
"func": ("set_seek_sync_mode", SeekSyncMode.PERCENT),
"check_if": ("is_seek_sync_mode_set_to", SeekSyncMode.PERCENT),
},
"Seek Sync (Timecode)": {
"title": translate("Actions", "Sync by timecode"),
"title": translate("Actions", "Sync By Timecode"),
"icon": "seek-sync-time",
"func": ("set_seek_sync_mode", SeekSyncMode.TIMECODE),
"check_if": ("is_seek_sync_mode_set_to", SeekSyncMode.TIMECODE),
Expand Down
9 changes: 9 additions & 0 deletions gridplayer/player/managers/menu.py
Expand Up @@ -19,6 +19,10 @@
"[ALL]": {"title": translate("Actions", "[ALL]"), "icon": "play-all"},
"Grid": {"title": translate("Actions", "Grid"), "icon": "grid"},
"Seek Sync": {"title": translate("Actions", "Seek Sync"), "icon": "seek-sync"},
"Seek Others": {
"title": translate("Actions", "Sync Others"),
"icon": "seek-sync",
},
}
)

Expand Down Expand Up @@ -85,6 +89,11 @@
"Aspect Stretch",
"Aspect None",
),
(
"Seek Others",
"Seek Others (Percent)",
"Seek Others (Timecode)",
),
"Stream Quality",
"Rename",
"Reload",
Expand Down
2 changes: 2 additions & 0 deletions gridplayer/player/managers/video_blocks.py
Expand Up @@ -258,6 +258,8 @@ def _add_video_block(self, video):
(vb.is_paused_change, self.playing_count_change),
(vb.sync_percent, self.seek_sync_percent),
(vb.sync_time, self.seek_sync_timecode),
(vb.sync_percent_single, self.all_seek_percent),
(vb.sync_time_single, self.all_seek),
(vb.sync_paused, self.set_pause),
(vb.destroyed, self._video_block_destroyed),
(self.set_pause, vb.set_pause),
Expand Down
14 changes: 14 additions & 0 deletions gridplayer/widgets/video_block.py
Expand Up @@ -150,6 +150,8 @@ class VideoBlock(QWidget): # noqa: WPS230

about_to_close = pyqtSignal(str)

sync_percent_single = pyqtSignal(float)
sync_time_single = pyqtSignal(int)
sync_percent = pyqtSignal(float)
sync_time = pyqtSignal(int)
sync_paused = pyqtSignal(bool)
Expand Down Expand Up @@ -422,6 +424,7 @@ def customEvent(self, event):
self.show_overlay()

@only_initialized
@only_seekable
def manual_seek(self, command, *args):
getattr(self, command)(*args)

Expand All @@ -432,6 +435,17 @@ def manual_seek(self, command, *args):
self.sync_time.emit(int(self.video_driver.length * self.position))

@only_initialized
@only_seekable
def sync_others_percent(self):
self.sync_percent_single.emit(self.position)

@only_initialized
@only_seekable
def sync_others_time(self):
self.sync_time_single.emit(int(self.video_driver.length * self.position))

@only_initialized
@only_seekable
def seek_timecode(self):
time_ms = QCustomSpinboxTimeInput.get_time_ms_int(
self.parent(), self.tr("Enter timecode")
Expand Down

0 comments on commit 90a0449

Please sign in to comment.