add trackid

- mpris important property (maybe needed sometime)
This commit is contained in:
Thanasis Trispiotis 2023-04-20 20:11:22 +03:00
parent a2a2023853
commit b2e68f5a8f
No known key found for this signature in database
GPG Key ID: F2CB994F68ED0802

View File

@ -300,6 +300,7 @@ function updateMediaInfo(options, notify) {
"xesam:album": options.album,
"mpris:artUrl": options.image,
"mpris:length": convertDuration(options.duration) * 1000 * 1000,
"mpris:trackid": "/org/mpris/MediaPlayer2/track/" + getTrackID(),
},
};
player.playbackStatus = options.status == statuses.paused ? "Paused" : "Playing";
@ -321,6 +322,16 @@ function getTrackURL() {
return window.location;
}
function getTrackID() {
const URLelement = elements.get("title").querySelector("a");
if (URLelement !== null) {
const id = URLelement.href.replace(/[^0-9]/g, "");
return id;
}
return window.location;
}
/**
* Watch for song changes and update title + notify
*/