mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-05-14 14:53:05 +02:00
Compare commits
No commits in common. "bccc979f4327183a1dae1ab9afb55dab5faf1d72" and "07be74af9f476a30d24836e9a0d5516cc94c6350" have entirely different histories.
bccc979f43
...
07be74af9f
@ -8,7 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### New features
|
### New features
|
||||||
|
|
||||||
- Added proper updates through the MediaSession API
|
|
||||||
- You can now add custom CSS in the "advanced" settings tab
|
- You can now add custom CSS in the "advanced" settings tab
|
||||||
- You can now configure the updateFrequency in the settings window
|
- You can now configure the updateFrequency in the settings window
|
||||||
- Default value is set to 500 and will overwrite the hardcoded value of 100
|
- Default value is set to 500 and will overwrite the hardcoded value of 100
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
extends: ./build/electron-builder.base.yml
|
extends: ./build/electron-builder.base.yml
|
||||||
linux:
|
linux:
|
||||||
|
icon: icon.png
|
||||||
target:
|
target:
|
||||||
- pacman
|
- pacman
|
||||||
|
@ -323,14 +323,14 @@ function updateMediaInfo(options, notify) {
|
|||||||
if (options) {
|
if (options) {
|
||||||
ipcRenderer.send(globalEvents.updateInfo, options);
|
ipcRenderer.send(globalEvents.updateInfo, options);
|
||||||
if (store.get(settings.notifications) && notify) {
|
if (store.get(settings.notifications) && notify) {
|
||||||
new Notification({ title: options.title, body: options.artists, icon: options.icon }).show();
|
new Notification({ title: options.title, body: options.message, icon: options.icon }).show();
|
||||||
}
|
}
|
||||||
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],
|
||||||
"xesam:album": options.album,
|
"xesam:album": options.album,
|
||||||
"mpris:artUrl": options.image,
|
"mpris:artUrl": options.image,
|
||||||
"mpris:length": convertDuration(options.duration) * 1000 * 1000,
|
"mpris:length": convertDuration(options.duration) * 1000 * 1000,
|
||||||
@ -361,23 +361,6 @@ function getTrackID() {
|
|||||||
return window.location;
|
return window.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMediaSession(options) {
|
|
||||||
if ("mediaSession" in navigator) {
|
|
||||||
navigator.mediaSession.metadata = new MediaMetadata({
|
|
||||||
title: options.title,
|
|
||||||
artist: options.artists,
|
|
||||||
album: options.album,
|
|
||||||
artwork: [
|
|
||||||
{
|
|
||||||
src: options.icon,
|
|
||||||
sizes: "640x640",
|
|
||||||
type: "image/png",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch for song changes and update title + notify
|
* Watch for song changes and update title + notify
|
||||||
*/
|
*/
|
||||||
@ -394,7 +377,7 @@ setInterval(function () {
|
|||||||
const currentStatus = getCurrentlyPlayingStatus();
|
const currentStatus = getCurrentlyPlayingStatus();
|
||||||
const options = {
|
const options = {
|
||||||
title,
|
title,
|
||||||
artists: artistsString,
|
message: artistsString,
|
||||||
album: album,
|
album: album,
|
||||||
status: currentStatus,
|
status: currentStatus,
|
||||||
url: getTrackURL(),
|
url: getTrackURL(),
|
||||||
@ -403,7 +386,7 @@ setInterval(function () {
|
|||||||
"app-name": appName,
|
"app-name": appName,
|
||||||
};
|
};
|
||||||
|
|
||||||
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
const titleOrArtistChanged = currentSong !== songDashArtistTitle;
|
||||||
|
|
||||||
// update title, url and play info with new info
|
// update title, url and play info with new info
|
||||||
setTitle(songDashArtistTitle);
|
setTitle(songDashArtistTitle);
|
||||||
@ -432,10 +415,7 @@ setInterval(function () {
|
|||||||
}
|
}
|
||||||
}).then(
|
}).then(
|
||||||
() => {
|
() => {
|
||||||
updateMediaInfo(options, titleOrArtistsChanged);
|
updateMediaInfo(options, titleOrArtistChanged);
|
||||||
if (titleOrArtistsChanged) {
|
|
||||||
updateMediaSession(options);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
() => {}
|
() => {}
|
||||||
);
|
);
|
||||||
|
@ -26,8 +26,8 @@ const observer = (event, arg) => {
|
|||||||
...idleStatus,
|
...idleStatus,
|
||||||
...{
|
...{
|
||||||
details: `Listening to ${mediaInfoModule.mediaInfo.title}`,
|
details: `Listening to ${mediaInfoModule.mediaInfo.title}`,
|
||||||
state: mediaInfoModule.mediaInfo.artists
|
state: mediaInfoModule.mediaInfo.artist
|
||||||
? mediaInfoModule.mediaInfo.artists
|
? mediaInfoModule.mediaInfo.artist
|
||||||
: "unknown artist(s)",
|
: "unknown artist(s)",
|
||||||
startTimestamp: parseInt(now),
|
startTimestamp: parseInt(now),
|
||||||
endTimestamp: parseInt(remaining),
|
endTimestamp: parseInt(remaining),
|
||||||
@ -43,7 +43,7 @@ const observer = (event, arg) => {
|
|||||||
...idleStatus,
|
...idleStatus,
|
||||||
...{
|
...{
|
||||||
details: `Watching ${mediaInfoModule.mediaInfo.title}`,
|
details: `Watching ${mediaInfoModule.mediaInfo.title}`,
|
||||||
state: mediaInfoModule.mediaInfo.artists,
|
state: mediaInfoModule.mediaInfo.artist,
|
||||||
startTimestamp: parseInt(now),
|
startTimestamp: parseInt(now),
|
||||||
endTimestamp: parseInt(remaining),
|
endTimestamp: parseInt(remaining),
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,7 @@ expressModule.run = function (mainWindow) {
|
|||||||
|
|
||||||
const expressApp = express();
|
const expressApp = express();
|
||||||
expressApp.get("/", (req, res) => res.send("Hello World!"));
|
expressApp.get("/", (req, res) => res.send("Hello World!"));
|
||||||
expressApp.get("/current", (req, res) => res.json({ ...mediaInfo, artist: mediaInfo.artists }));
|
expressApp.get("/current", (req, res) => res.json(mediaInfo));
|
||||||
expressApp.get("/image", (req, res) => {
|
expressApp.get("/image", (req, res) => {
|
||||||
var stream = fs.createReadStream(mediaInfo.icon);
|
var stream = fs.createReadStream(mediaInfo.icon);
|
||||||
stream.on("open", function() {
|
stream.on("open", function() {
|
||||||
|
@ -2,14 +2,14 @@ const statuses = require("./../constants/statuses");
|
|||||||
|
|
||||||
const mediaInfo = {
|
const mediaInfo = {
|
||||||
title: "",
|
title: "",
|
||||||
artists: "",
|
artist: "",
|
||||||
album: "",
|
album: "",
|
||||||
icon: "",
|
icon: "",
|
||||||
status: statuses.paused,
|
status: statuses.paused,
|
||||||
url: "",
|
url: "",
|
||||||
current: "",
|
current: "",
|
||||||
duration: "",
|
duration: "",
|
||||||
image: "tidal-hifi-icon",
|
image: "tidal-hifi-icon"
|
||||||
};
|
};
|
||||||
const mediaInfoModule = {
|
const mediaInfoModule = {
|
||||||
mediaInfo,
|
mediaInfo,
|
||||||
@ -20,7 +20,7 @@ const mediaInfoModule = {
|
|||||||
*/
|
*/
|
||||||
mediaInfoModule.update = function (arg) {
|
mediaInfoModule.update = function (arg) {
|
||||||
mediaInfo.title = propOrDefault(arg.title);
|
mediaInfo.title = propOrDefault(arg.title);
|
||||||
mediaInfo.artists = propOrDefault(arg.artists);
|
mediaInfo.artist = propOrDefault(arg.message);
|
||||||
mediaInfo.album = propOrDefault(arg.album);
|
mediaInfo.album = propOrDefault(arg.album);
|
||||||
mediaInfo.icon = propOrDefault(arg.icon);
|
mediaInfo.icon = propOrDefault(arg.icon);
|
||||||
mediaInfo.url = propOrDefault(arg.url);
|
mediaInfo.url = propOrDefault(arg.url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user