Skip to content

Commit

Permalink
Allow disabling raise_mpv and also only do it once per play. (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwalton3 committed Jun 11, 2022
1 parent 5a99a99 commit 4be2572
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion jellyfin_mpv_shim/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
7 changes: 4 additions & 3 deletions jellyfin_mpv_shim/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion jellyfin_mpv_shim/syncplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4be2572

Please sign in to comment.