From 4be2572ca413742180d0d8da1c652e688afb67d3 Mon Sep 17 00:00:00 2001 From: Ian Walton Date: Sat, 11 Jun 2022 00:27:01 -0400 Subject: [PATCH] Allow disabling raise_mpv and also only do it once per play. (#218) --- README.md | 1 + jellyfin_mpv_shim/event_handler.py | 2 +- jellyfin_mpv_shim/player.py | 7 ++++--- jellyfin_mpv_shim/syncplay.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9a8b4d963d..e9e3e357fd 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,7 @@ Other miscellaneous configuration options. You probably won't have to change the - Default is the desktop on Windows and unset (current directory) on other platforms. - `force_set_played` - This forcibly sets items as played when MPV playback finished. - If you have files with malformed timestamps that don't get marked as played, enable this. + - `raise_mpv` - Windows only. Disable this if you are fine with MPV sometimes appearing behind other windows when playing. ### MPV Configuration diff --git a/jellyfin_mpv_shim/event_handler.py b/jellyfin_mpv_shim/event_handler.py index 322a2aeff5..0a0ee85d91 100644 --- a/jellyfin_mpv_shim/event_handler.py +++ b/jellyfin_mpv_shim/event_handler.py @@ -78,7 +78,7 @@ def play_media(self, client: "JellyfinClient_type", _event_name, arguments: dict if video: if settings.pre_media_cmd: os.system(settings.pre_media_cmd) - playerManager.play(video, offset) + playerManager.play(video, offset, is_initial_play=True) timelineManager.send_timeline() if arguments.get("SyncPlayGroup") is not None: playerManager.syncplay.join_group(arguments["SyncPlayGroup"]) diff --git a/jellyfin_mpv_shim/player.py b/jellyfin_mpv_shim/player.py index 4f3de9d437..48554094d8 100644 --- a/jellyfin_mpv_shim/player.py +++ b/jellyfin_mpv_shim/player.py @@ -424,7 +424,7 @@ def update(self): self.last_update.restart() def play( - self, video: "Video_type", offset: int = 0, no_initial_timeline: bool = False + self, video: "Video_type", offset: int = 0, no_initial_timeline: bool = False, is_initial_play: bool = False ): self.should_send_timeline = False self.start_time = time.time() @@ -433,7 +433,7 @@ def play( log.error("PlayerManager::play no URL found") return - self._play_media(video, url, offset, no_initial_timeline) + self._play_media(video, url, offset, no_initial_timeline, is_initial_play) @synchronous("_lock") def _play_media( @@ -442,6 +442,7 @@ def _play_media( url: str, offset: int = 0, no_initial_timeline: bool = False, + is_initial_play: bool = False ): self.pause_ignore = True self.do_not_handle_pause = True @@ -474,7 +475,7 @@ def _play_media( self.configure_streams() self.update_subtitle_visuals() - if win_utils: + if win_utils and settings.raise_mpv and is_initial_play: win_utils.raise_mpv() if offset is not None and offset > 0: diff --git a/jellyfin_mpv_shim/syncplay.py b/jellyfin_mpv_shim/syncplay.py index d16a4ac766..ccdfb2436b 100644 --- a/jellyfin_mpv_shim/syncplay.py +++ b/jellyfin_mpv_shim/syncplay.py @@ -425,7 +425,7 @@ def prepare_session(self, group_id: str, session_data: dict): if video: if settings.pre_media_cmd: os.system(settings.pre_media_cmd) - self.playerManager.play(video, offset, no_initial_timeline=True) + self.playerManager.play(video, offset, no_initial_timeline=True, is_initial_play=True) self.playerManager.send_timeline() # Really not sure why I have to call this. self.join_group(group_id)