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:
Rick van Lieshout 2021-11-29 22:43:51 +01:00 committed by GitHub
parent 8fea5265e7
commit 5ef6074015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -20,6 +20,7 @@ The web version of [listen.tidal.com](https://listen.tidal.com) running in elect
- [Integrations](#integrations) - [Integrations](#integrations)
- [not included](#not-included) - [not included](#not-included)
- [Known bugs](#known-bugs) - [Known bugs](#known-bugs)
- [last.fm doesn't work out of the box. Use rescrobbler as a workaround](#lastfm-doesnt-work-out-of-the-box-use-rescrobbler-as-a-workaround)
- [Why](#why) - [Why](#why)
- [Why not extend existing projects?](#why-not-extend-existing-projects) - [Why not extend existing projects?](#why-not-extend-existing-projects)
- [Special thanks to...](#special-thanks-to) - [Special thanks to...](#special-thanks-to)
@ -96,7 +97,11 @@ It currently includes:
### Known bugs ### Known bugs
- [Last.fm login doesn't work](https://github.com/Mastermindzh/tidal-hifi/issues/4). #### last.fm doesn't work out of the box. Use rescrobbler as a workaround
The last.fm login doesn't work, as is evident from the following issue: [Last.fm login doesn't work](https://github.com/Mastermindzh/tidal-hifi/issues/4).
However, in that same issue you can read about a workaround using [rescrobbler](https://github.com/InputUsername/rescrobbled).
For now that will be the default workaround.
## Why ## Why

View File

@ -1,6 +1,6 @@
{ {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "2.3.0", "version": "2.4.0",
"description": "Tidal on Electron with widevine(hifi) support", "description": "Tidal on Electron with widevine(hifi) support",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -234,6 +234,15 @@ function getCurrentlyPlayingStatus() {
return status; 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 * Update Tidal-hifi's media info
* *
@ -243,14 +252,14 @@ function updateMediaInfo(options, notify) {
if (options) { if (options) {
ipcRenderer.send(globalEvents.updateInfo, options); ipcRenderer.send(globalEvents.updateInfo, options);
store.get(settings.notifications) && notify && notifier.notify(options); store.get(settings.notifications) && notify && notifier.notify(options);
if (player) { if (player) {
player.metadata = { player.metadata = {
...player.metadata, ...player.metadata,
...{ ...{
"xesam:title": options.title, "xesam:title": options.title,
"xesam:artist": [options.artists], "xesam:artist": [options.message],
"mpris:artUrl": options.image, "mpris:artUrl": options.image,
"mpris:length": convertDuration(options.duration) * 1000 * 1000,
}, },
}; };
player.playbackStatus = options.status == statuses.paused ? "Paused" : "Playing"; player.playbackStatus = options.status == statuses.paused ? "Paused" : "Playing";
@ -331,6 +340,7 @@ setInterval(function () {
new Promise((resolve) => { new Promise((resolve) => {
if (image.startsWith("http")) { if (image.startsWith("http")) {
options.image = image;
downloadFile(image, notificationPath).then( downloadFile(image, notificationPath).then(
() => { () => {
options.icon = notificationPath; 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 () { player.on("quit", function () {
app.quit(); app.quit();