Compare commits

..

No commits in common. "bccc979f4327183a1dae1ab9afb55dab5faf1d72" and "07be74af9f476a30d24836e9a0d5516cc94c6350" have entirely different histories.

6 changed files with 17 additions and 37 deletions

View File

@ -8,7 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### New features
- Added proper updates through the MediaSession API
- You can now add custom CSS in the "advanced" settings tab
- You can now configure the updateFrequency in the settings window
- Default value is set to 500 and will overwrite the hardcoded value of 100

View File

@ -1,4 +1,5 @@
extends: ./build/electron-builder.base.yml
linux:
icon: icon.png
target:
- pacman

View File

@ -323,14 +323,14 @@ function updateMediaInfo(options, notify) {
if (options) {
ipcRenderer.send(globalEvents.updateInfo, options);
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) {
player.metadata = {
...player.metadata,
...{
"xesam:title": options.title,
"xesam:artist": [options.artists],
"xesam:artist": [options.message],
"xesam:album": options.album,
"mpris:artUrl": options.image,
"mpris:length": convertDuration(options.duration) * 1000 * 1000,
@ -361,23 +361,6 @@ function getTrackID() {
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
*/
@ -394,7 +377,7 @@ setInterval(function () {
const currentStatus = getCurrentlyPlayingStatus();
const options = {
title,
artists: artistsString,
message: artistsString,
album: album,
status: currentStatus,
url: getTrackURL(),
@ -403,7 +386,7 @@ setInterval(function () {
"app-name": appName,
};
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
const titleOrArtistChanged = currentSong !== songDashArtistTitle;
// update title, url and play info with new info
setTitle(songDashArtistTitle);
@ -432,10 +415,7 @@ setInterval(function () {
}
}).then(
() => {
updateMediaInfo(options, titleOrArtistsChanged);
if (titleOrArtistsChanged) {
updateMediaSession(options);
}
updateMediaInfo(options, titleOrArtistChanged);
},
() => {}
);

View File

@ -26,8 +26,8 @@ const observer = (event, arg) => {
...idleStatus,
...{
details: `Listening to ${mediaInfoModule.mediaInfo.title}`,
state: mediaInfoModule.mediaInfo.artists
? mediaInfoModule.mediaInfo.artists
state: mediaInfoModule.mediaInfo.artist
? mediaInfoModule.mediaInfo.artist
: "unknown artist(s)",
startTimestamp: parseInt(now),
endTimestamp: parseInt(remaining),
@ -43,7 +43,7 @@ const observer = (event, arg) => {
...idleStatus,
...{
details: `Watching ${mediaInfoModule.mediaInfo.title}`,
state: mediaInfoModule.mediaInfo.artists,
state: mediaInfoModule.mediaInfo.artist,
startTimestamp: parseInt(now),
endTimestamp: parseInt(remaining),
},

View File

@ -24,7 +24,7 @@ expressModule.run = function (mainWindow) {
const expressApp = express();
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) => {
var stream = fs.createReadStream(mediaInfo.icon);
stream.on("open", function() {

View File

@ -2,14 +2,14 @@ const statuses = require("./../constants/statuses");
const mediaInfo = {
title: "",
artists: "",
artist: "",
album: "",
icon: "",
status: statuses.paused,
url: "",
current: "",
duration: "",
image: "tidal-hifi-icon",
image: "tidal-hifi-icon"
};
const mediaInfoModule = {
mediaInfo,
@ -20,7 +20,7 @@ const mediaInfoModule = {
*/
mediaInfoModule.update = function (arg) {
mediaInfo.title = propOrDefault(arg.title);
mediaInfo.artists = propOrDefault(arg.artists);
mediaInfo.artist = propOrDefault(arg.message);
mediaInfo.album = propOrDefault(arg.album);
mediaInfo.icon = propOrDefault(arg.icon);
mediaInfo.url = propOrDefault(arg.url);