Skip to content

player: restart playback when eof reached#17934

Open
HaHaWTH wants to merge 2 commits into
mpv-player:masterfrom
HaHaWTH:fix/smtc-eof-playback
Open

player: restart playback when eof reached#17934
HaHaWTH wants to merge 2 commits into
mpv-player:masterfrom
HaHaWTH:fix/smtc-eof-playback

Conversation

@HaHaWTH
Copy link
Copy Markdown

@HaHaWTH HaHaWTH commented May 17, 2026

Description

When playback reaches EOF with --keep-open=yes and loop file is disabled, mpv keeps the file open and sets eof-reached. Pressing Play in SMTC currently only clears pause, but does not restart playback.

This PR seeks to the beginning first if eof-reached is true, then unpause. Pressing Play while paused before EOF continues to behave as before.

When playback reaches EOF with --keep-open=yes and loop file is disabled, mpv keeps the file open and enters the EOF state. Since --keep-open normally acts like set pause yes on EOF, pressing Play or any other stuff that setting pause=no only clears the pause state, but does not restart playback.

This PR handles the EOF restart, when unpausing from a keep-open EOF state, mpv seeks back to the file start position before resuming playback.

This makes the behavior consistent across SMTC, osc display, keyboard bindings unpause.

Testing

  • Windows 11 version 25H2 (26200.8457)
  • --keep-open=yes --loop-file=no --loop-playlist=no
  • Windows SMTC Play
  • OSC play button
  • keyboard play/pause

@garoto
Copy link
Copy Markdown
Contributor

garoto commented May 17, 2026

What is wrong with <keybind> seek 0 absolute?

@HaHaWTH
Copy link
Copy Markdown
Author

HaHaWTH commented May 18, 2026

What is wrong with <keybind> seek 0 absolute?

Some use cases of SMTC control is when the user does not have immediate access to the keyboard or the mpv window is minimized to background, using smtc buttons will be more convenient.

Also if --keep-open=yes is set, pressing play via SMTC at EOF simply clears the pause state but does nothing else, pressing Play at the end of a track should restart it.

@kasper93
Copy link
Copy Markdown
Member

Pressing Play in SMTC currently only clears pause, but does not restart playback.

This is how play/pause state works in mpv. It's not specific to SMTC, and I don't think we should add specific handling for it. OSC works the same way, pressing play button, does "nothing" when we are at EOF. If fixes are needed here it should be done in common code that makes behavior consistent across all interfaces.

@HaHaWTH

This comment was marked as resolved.

@HaHaWTH HaHaWTH force-pushed the fix/smtc-eof-playback branch from 06197e2 to 0feabf1 Compare May 18, 2026 14:58
@HaHaWTH HaHaWTH force-pushed the fix/smtc-eof-playback branch from 0feabf1 to 80d632e Compare May 18, 2026 14:59
@HaHaWTH
Copy link
Copy Markdown
Author

HaHaWTH commented May 18, 2026

I've moved EOF restart logic to common player path, tested locally without issues. sorry if I missed something

@HaHaWTH HaHaWTH changed the title restart playback when eof reached player: restart playback when eof reached May 18, 2026
the context has been set to KEEP_PLAYING in handle_keep_open, assuming there's no need to set again
@HaHaWTH
Copy link
Copy Markdown
Author

HaHaWTH commented May 21, 2026

After moving changes into common player path, seems related to #11183 now; the keybind solution works in most cases, but not suitable for SMTC control. SMTC media controls issue an unpause request, keybinds did not cover this path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants