mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-07-28 00:22:26 +02:00
Release 2.4.0 (#74)
Update MPRIS functionality to provide length, artist, and current position. Also added rescrobbler explanation to the README. Co-authored-by: Vinay V <cool00geek@yahoo.com>
This commit is contained in:
@@ -234,6 +234,15 @@ function getCurrentlyPlayingStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the duration from MM:SS to seconds
|
||||
* @param {*} duration
|
||||
*/
|
||||
function convertDuration(duration) {
|
||||
const parts = duration.split(":");
|
||||
return parseInt(parts[1]) + 60 * parseInt(parts[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Tidal-hifi's media info
|
||||
*
|
||||
@@ -243,14 +252,14 @@ function updateMediaInfo(options, notify) {
|
||||
if (options) {
|
||||
ipcRenderer.send(globalEvents.updateInfo, options);
|
||||
store.get(settings.notifications) && notify && notifier.notify(options);
|
||||
|
||||
if (player) {
|
||||
player.metadata = {
|
||||
...player.metadata,
|
||||
...{
|
||||
"xesam:title": options.title,
|
||||
"xesam:artist": [options.artists],
|
||||
"xesam:artist": [options.message],
|
||||
"mpris:artUrl": options.image,
|
||||
"mpris:length": convertDuration(options.duration) * 1000 * 1000,
|
||||
},
|
||||
};
|
||||
player.playbackStatus = options.status == statuses.paused ? "Paused" : "Playing";
|
||||
@@ -331,6 +340,7 @@ setInterval(function () {
|
||||
|
||||
new Promise((resolve) => {
|
||||
if (image.startsWith("http")) {
|
||||
options.image = image;
|
||||
downloadFile(image, notificationPath).then(
|
||||
() => {
|
||||
options.icon = notificationPath;
|
||||
@@ -397,6 +407,10 @@ if (process.platform === "linux" && store.get(settings.mpris)) {
|
||||
}
|
||||
});
|
||||
});
|
||||
// Override get position function
|
||||
player.getPosition = function () {
|
||||
return convertDuration(elements.getText("current")) * 1000 * 1000;
|
||||
};
|
||||
|
||||
player.on("quit", function () {
|
||||
app.quit();
|
||||
|
Reference in New Issue
Block a user