Skip to content

Commit

Permalink
add trackid
Browse files Browse the repository at this point in the history
- mpris important property (maybe needed sometime)
  • Loading branch information
thanasistrisp committed Apr 20, 2023
1 parent a2a2023 commit b2e68f5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
*/
Expand Down

0 comments on commit b2e68f5

Please sign in to comment.