Skip to content

Set CanPlay/CanPause based on mpv idle state#133

Open
jack-mil wants to merge 1 commit into
hoyon:masterfrom
jack-mil:fix/canPlay
Open

Set CanPlay/CanPause based on mpv idle state#133
jack-mil wants to merge 1 commit into
hoyon:masterfrom
jack-mil:fix/canPlay

Conversation

@jack-mil

Copy link
Copy Markdown

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 to g_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.

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.
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.

1 participant