Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SetPosition, Position and other mpris properties #10

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

antlarr
Copy link

@antlarr antlarr commented Aug 10, 2017

Added support for callbacks when getting values so there's no need
to keep a variable updated and so we can provide the current media
position throught mpris' Position property

Added support for SetPosition so mpris clients can seek freely.

Fix media length reporting (which was always nil) by getting the
mpris:length value from the duration property.

Fill values for the following metadata:
xesam:album
xesam:albumArtist
xesam:artist
xesam:trackNumber
xesam:genre
xesam:lyricist
xesam:discNumber
mpris:trackid
mpris:artUrl
xesam:url

Note that mpris:trackid has a fixed value (it needs to be a dbus
object reference). This value is later provided by the mpris client
as the first parameter of SetPosition.

Also, in order to find out the full path of the url, we need to find
out the current working directory, which requires to add lfs as a
dependency. Maybe there's another way to find out the CWD but I
don't know so much lua. Also, to show the artUrl, a 'cover.jpg'
file has to be available in the same directory as the media. The ideal
solution would be to extract the cover from the music file, but again,
that's beyond my lua knowledge.

This makes KDE Plasma mediacontroller completely usable to control
mpv.

antlarr and others added 11 commits August 10, 2017 09:47
Added support for callbacks when getting values so there's no need
to keep a variable updated and so we can provide the current media
position throught mpris' Position property

Added support for SetPosition so mpris clients can seek freely.

Fix media length reporting (which was always nil) by getting the
mpris:length value from the duration property.

Fill values for the following metadata:
xesam:album
xesam:albumArtist
xesam:artist
xesam:trackNumber
xesam:genre
xesam:lyricist
xesam:discNumber
mpris:trackid
mpris:artUrl
xesam:url

Note that mpris:trackid has a fixed value (it needs to be a dbus
object reference). This value is later provided by the mpris client
as the first parameter of SetPosition.

Also, in order to find out the full path of the url, we need to find
out the current working directory, which requires to add lfs as a
dependency. Maybe there's another way to find out the CWD but I
don't know so much lua. Also, to show the artUrl, a 'cover.jpg'
file has to be available in the same directory as the media. The ideal
solution would be to extract the cover from the music file, but again,
that's beyond my lua knowledge.

This makes KDE Plasma mediacontroller completely usable to control
mpv.
Added a MIT license as that's what the original author wanted to have according to the mpris-scm-0.rockspec file
Use mp.utils to get the CWD and to split/join paths instead of lfs and
custom code that didn't work with absolute paths for filenames
Also, move static variables to the beginning of the file
This fixes the mpv.lua script to work when everything is installed
on the system as it should be.
This way, if a file sets a value for artUrl and the next file in the
playlist doesn't have a valid artUrl, it gets initialized to nil instead
of keeping the old value
Fix a reference to nil by checking the table to be searched before using it.
When sending the metadata of the file through dbus, the dbus library
was making mpv crash because it wasn't accepting invalid utf8 encoded
strings. We now remove all invalid characters when setting
the metadata that will be sent through dbus which should fix the issue.
The fix in 1281dcd didn't work
for some characters, making the function remove valid utf-8 characters.

This patch takes a different approach which works better by matching
the bytes sequences against valid sequences patterns.
It seems I renamed a table/function and forgot to rename some
occurrences.
…perties

The media controller applet in Plasma 5.17 now requires those two properties
to be set up correctly or otherwise it ignores the mpris client, so we now have
to set those variables correctly in order to be useful in Plasma.
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