Set CanPlay/CanPause based on mpv idle state#133
Open
jack-mil wants to merge 1 commit into
Open
Conversation
The MPRIS specification says that the CanPlay and CanPause boolean
properties should be set to reflect the state of the media player. When
MPV is run as a background daemon ("idle operation") such as with
`jellyfin-mpv-shim`, it is not always correct to assume CanPlay or
CanPause should be true when content is not being played in MPV.
Some MPRIS clients use the CanPlay property as an indicator to show/hide
the media player controls. This commit makes it so than when mpv goes
into the idle state, and the MPRIS PlaybackStatus is set to Stopped,
CanPlay and CanPause are also set to false.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there, I've made a small modification that solved a minor annoyance with my use case.
When MPV is run as a background daemon such as with
jellyfin-mpv-shim, the process is often in a stopped idle state with no video currently playing.Some MPRIS clients use the CanPlay property as an indicator to show/hide the media player controls. This commit makes it so than when mpv goes into the idle state, and the MPRIS PlaybackStatus is set to Stopped, CanPlay and CanPause are also set to
false.According to my interpretation of the MPRIS specification, I think this is the correct operation when MPV is not playing a video (but is running in the idle state). The spec says that the CanPlay and CanPause boolean properties should be set to reflect the state of the media player.
I am not familiar with the code base, so I will in no way take offense if you want to ignore this PR or re-write with a different implementation. Just thought I would share what was working for me.
PS. I don't know anything about GLib, but I was somewhat confused when writing this about where in the code all the
GVariants created from calls tog_variant_new_*()are freed. I imagine there is some magic library-handled cleanup that I missed. Maybe that is a non-issue, but it made me think.