Playback notifications working, actions scrapped because mac build is unable to play music.
This commit is contained in:
parent
bb77f08314
commit
1b3bd3163d
1 changed files with 12 additions and 10 deletions
|
@ -140,7 +140,7 @@ const app = new Vue({
|
||||||
end: 0
|
end: 0
|
||||||
},
|
},
|
||||||
tmpVar: [],
|
tmpVar: [],
|
||||||
notification: {},
|
notification: false,
|
||||||
chrome: {
|
chrome: {
|
||||||
hideUserInfo: false,
|
hideUserInfo: false,
|
||||||
artworkReady: false,
|
artworkReady: false,
|
||||||
|
@ -156,6 +156,7 @@ const app = new Vue({
|
||||||
title: "",
|
title: "",
|
||||||
type: ""
|
type: ""
|
||||||
},
|
},
|
||||||
|
currentSongInfo: {},
|
||||||
page: "artist-page",
|
page: "artist-page",
|
||||||
pageHistory: [],
|
pageHistory: [],
|
||||||
songstest: false
|
songstest: false
|
||||||
|
@ -193,6 +194,7 @@ const app = new Vue({
|
||||||
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
||||||
|
this.currentSongInfo = a
|
||||||
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)
|
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)
|
||||||
self.lyriccurrenttime = app.mk.currentPlaybackTime;
|
self.lyriccurrenttime = app.mk.currentPlaybackTime;
|
||||||
|
|
||||||
|
@ -259,6 +261,9 @@ const app = new Vue({
|
||||||
})
|
})
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.nowPlayingItemDidChange, (a) => {
|
this.mk.addEventListener(MusicKit.Events.nowPlayingItemDidChange, (a) => {
|
||||||
|
this.currentSongInfo = a
|
||||||
|
a = a.item.attributes;
|
||||||
|
|
||||||
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ?? '' : '';
|
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ?? '' : '';
|
||||||
|
|
||||||
if (type.includes("musicVideo") || type.includes("uploadedVideo")) {
|
if (type.includes("musicVideo") || type.includes("uploadedVideo")) {
|
||||||
|
@ -275,18 +280,15 @@ const app = new Vue({
|
||||||
app.loadLyrics()
|
app.loadLyrics()
|
||||||
|
|
||||||
// Playback Notifications
|
// Playback Notifications
|
||||||
if (app.platform == "darwin" || app.platform == "linux") {
|
if ((app.platform === "darwin" || app.platform === "linux") && !document.hasFocus()) {
|
||||||
self.notification = new Notification(a.title, {
|
if (this.notification) {
|
||||||
|
this.notification.close()
|
||||||
|
}
|
||||||
|
this.notification = new Notification(a.name, {
|
||||||
body: a.artistName,
|
body: a.artistName,
|
||||||
icon: a.artwork.url,
|
icon: (a.artwork.url.replace('/{w}x{h}bb', '/512x512bb')).replace('/2000x2000bb', '/35x35bb'),
|
||||||
actions: [{"skip": "Skip"}],
|
|
||||||
silent: true
|
silent: true
|
||||||
})
|
})
|
||||||
// self.notification.addEventListener('notificationclick', function(event) {
|
|
||||||
// event.notification.close();
|
|
||||||
// if (event.action !== 'skip') return;
|
|
||||||
// this.mk.skipToNext
|
|
||||||
// }, false);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue