added app.openAppleMusicURL(url) function

This commit is contained in:
booploops 2022-01-13 01:59:40 -08:00
parent a5a8a09d04
commit 12be6212e8
2 changed files with 242 additions and 191 deletions

View file

@ -52,7 +52,7 @@ var CiderContextMenu = {
} }
item.tabIndex = 0 item.tabIndex = 0
item.classList.add("context-menu-item") item.classList.add("context-menu-item")
if(menudata.items[i]["icon"]) { if (menudata.items[i]["icon"]) {
item.innerHTML += `<div class="sidebar-icon">${await app.getSvgIcon(menudata.items[i]["icon"])}</div>` item.innerHTML += `<div class="sidebar-icon">${await app.getSvgIcon(menudata.items[i]["icon"])}</div>`
} }
item.innerHTML += menudata.items[i].name item.innerHTML += menudata.items[i].name
@ -322,6 +322,21 @@ const app = new Vue({
}, },
}, },
methods: { methods: {
async openAppleMusicURL(url) {
let properties = MusicKit.formattedMediaURL(url)
let item = {
id: properties.contentId,
attributes: {
playParams: {
id: properties.contentId,
kind: properties.kind,
}
},
type: properties.kind,
kind: properties.kind
}
app.routeView(item)
},
async showMenuPanel(data) { async showMenuPanel(data) {
app.menuPanel.visible = true; app.menuPanel.visible = true;
app.menuPanel.content.name = data.name ?? ""; app.menuPanel.content.name = data.name ?? "";
@ -388,10 +403,12 @@ const app = new Vue({
id: self.selectedMediaItems[i].id, id: self.selectedMediaItems[i].id,
type: self.selectedMediaItems[i].kind type: self.selectedMediaItems[i].kind
}) })
} else if ((self.selectedMediaItems[i].kind == "album" || self.selectedMediaItems[i].kind == "albums") && self.selectedMediaItems[i].isLibrary != true ) { } else if ((self.selectedMediaItems[i].kind == "album" || self.selectedMediaItems[i].kind == "albums") && self.selectedMediaItems[i].isLibrary != true) {
self.selectedMediaItems[i].kind = "albums" self.selectedMediaItems[i].kind = "albums"
let res = await self.mk.api.albumRelationship(self.selectedMediaItems[i].id,"tracks"); let res = await self.mk.api.albumRelationship(self.selectedMediaItems[i].id, "tracks");
let ids = res.map(function(i) {return {id:i.id, type: i.type}}) let ids = res.map(function (i) {
return {id: i.id, type: i.type}
})
pl_items = pl_items.concat(ids) pl_items = pl_items.concat(ids)
} else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") { } else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") {
self.selectedMediaItems[i].kind = "library-songs" self.selectedMediaItems[i].kind = "library-songs"
@ -399,10 +416,12 @@ const app = new Vue({
id: self.selectedMediaItems[i].id, id: self.selectedMediaItems[i].id,
type: self.selectedMediaItems[i].kind type: self.selectedMediaItems[i].kind
}) })
} else if ((self.selectedMediaItems[i].kind == "library-album" || self.selectedMediaItems[i].kind == "library-albums") || (self.selectedMediaItems[i].kind == "album" && self.selectedMediaItems[i].isLibrary == true )) { } else if ((self.selectedMediaItems[i].kind == "library-album" || self.selectedMediaItems[i].kind == "library-albums") || (self.selectedMediaItems[i].kind == "album" && self.selectedMediaItems[i].isLibrary == true)) {
self.selectedMediaItems[i].kind = "library-albums" self.selectedMediaItems[i].kind = "library-albums"
let res = await self.mk.api.library.albumRelationship(self.selectedMediaItems[i].id,"tracks"); let res = await self.mk.api.library.albumRelationship(self.selectedMediaItems[i].id, "tracks");
let ids = res.map(function(i) {return {id:i.id, type: i.type}}) let ids = res.map(function (i) {
return {id: i.id, type: i.type}
})
pl_items = pl_items.concat(ids) pl_items = pl_items.concat(ids)
} else { } else {
pl_items.push({ pl_items.push({
@ -637,7 +656,7 @@ const app = new Vue({
}, 500) }, 500)
}, },
getAppClasses() { getAppClasses() {
if(this.cfg.advanced.experiments.includes('compactui')) { if (this.cfg.advanced.experiments.includes('compactui')) {
return {compact: true} return {compact: true}
} }
}, },
@ -892,7 +911,9 @@ const app = new Vue({
"fields[catalog]": "artistUrl,albumUrl", "fields[catalog]": "artistUrl,albumUrl",
"fields[songs]": "artistUrl,albumUrl" "fields[songs]": "artistUrl,albumUrl"
} }
if (!transient) {this.playlists.loadingState = 0;} if (!transient) {
this.playlists.loadingState = 0;
}
let playlistId = '' let playlistId = ''
try { try {
@ -1044,7 +1065,7 @@ const app = new Vue({
document.querySelector("#app-content").scrollTop = 0 document.querySelector("#app-content").scrollTop = 0
} else if (kind.toString().includes("artist")) { } else if (kind.toString().includes("artist")) {
app.getArtistInfo(id, isLibrary) app.getArtistInfo(id, isLibrary)
window.location.hash = `${kind}/${id}${isLibrary ? "/"+isLibrary : ''}` window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ''}`
document.querySelector("#app-content").scrollTop = 0 document.querySelector("#app-content").scrollTop = 0
} else if (kind.toString().includes("record-label") || kind.toString().includes("curator")) { } else if (kind.toString().includes("record-label") || kind.toString().includes("curator")) {
@ -1065,7 +1086,7 @@ const app = new Vue({
let params = {extend: "editorialVideo"} let params = {extend: "editorialVideo"}
app.page = (kind) + "_" + (id); app.page = (kind) + "_" + (id);
app.getTypeFromID((kind), (id), (isLibrary), params); app.getTypeFromID((kind), (id), (isLibrary), params);
window.location.hash = `${kind}/${id}${isLibrary ? "/"+isLibrary : ''}` window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ''}`
document.querySelector("#app-content").scrollTop = 0 document.querySelector("#app-content").scrollTop = 0
} else { } else {
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '') app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
@ -1560,6 +1581,7 @@ const app = new Vue({
this.library.songs.downloadState = 1 this.library.songs.downloadState = 1
this.library.downloadNotification.show = true this.library.downloadNotification.show = true
this.library.downloadNotification.message = "Updating library songs..." this.library.downloadNotification.message = "Updating library songs..."
function downloadChunk() { function downloadChunk() {
const params = { const params = {
"include[library-songs]": "catalog,artists,albums", "include[library-songs]": "catalog,artists,albums",
@ -1580,7 +1602,8 @@ const app = new Vue({
if (downloaded.next != null && typeof downloaded.next === "function") { if (downloaded.next != null && typeof downloaded.next === "function") {
downloaded.next("", params, {includeResponseMeta: !0}).then((response) => { downloaded.next("", params, {includeResponseMeta: !0}).then((response) => {
processChunk(response) processChunk(response)
}) } else { })
} else {
console.log("Download next", downloaded.next) console.log("Download next", downloaded.next)
} }
} }
@ -1659,7 +1682,8 @@ const app = new Vue({
if (downloaded.next != null && typeof downloaded.next === "function") { if (downloaded.next != null && typeof downloaded.next === "function") {
downloaded.next("", params, {includeResponseMeta: !0}).then((response) => { downloaded.next("", params, {includeResponseMeta: !0}).then((response) => {
processChunk(response) processChunk(response)
}) } else { })
} else {
console.log("Download next", downloaded.next) console.log("Download next", downloaded.next)
} }
} }
@ -1739,7 +1763,8 @@ const app = new Vue({
if (downloaded.next != null && typeof downloaded.next === "function") { if (downloaded.next != null && typeof downloaded.next === "function") {
downloaded.next("", "artists", {includeResponseMeta: !0}).then((response) => { downloaded.next("", "artists", {includeResponseMeta: !0}).then((response) => {
processChunk(response) processChunk(response)
}) } else { })
} else {
console.log("Download next", downloaded.next) console.log("Download next", downloaded.next)
} }
@ -1788,7 +1813,7 @@ const app = new Vue({
let hours = Math.floor(time / 3600) let hours = Math.floor(time / 3600)
let mins = Math.floor(time / 60) % 60 let mins = Math.floor(time / 60) % 60
let secs = time % 60 let secs = time % 60
return app.showingPlaylist.relationships.tracks.data.length + " track"+ (app.showingPlaylist.relationships.tracks.data.length > 1 ? "s" : "") +", " + ((hours > 0) ? (hours + (" hour" + ((hours > 1) ? "s, " : ", "))) : "") + ((mins > 0) ? (mins + (" minute" + ((mins > 1) ? "s, " : ", "))) : "") + secs + (" second" + ((secs > 1) ? "s." : ".")); return app.showingPlaylist.relationships.tracks.data.length + " track" + (app.showingPlaylist.relationships.tracks.data.length > 1 ? "s" : "") + ", " + ((hours > 0) ? (hours + (" hour" + ((hours > 1) ? "s, " : ", "))) : "") + ((mins > 0) ? (mins + (" minute" + ((mins > 1) ? "s, " : ", "))) : "") + secs + (" second" + ((secs > 1) ? "s." : "."));
} else return "" } else return ""
} catch (err) { } catch (err) {
return "" return ""
@ -2362,6 +2387,7 @@ const app = new Vue({
array[j] = temp; array[j] = temp;
} }
} }
let kind = parent.substring(0, parent.indexOf(":")) let kind = parent.substring(0, parent.indexOf(":"))
let id = parent.substring(parent.indexOf(":") + 1, parent.length) let id = parent.substring(parent.indexOf(":") + 1, parent.length)
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
@ -2379,7 +2405,9 @@ const app = new Vue({
app.mk.stop().then(() => { app.mk.stop().then(() => {
this.mk.clearQueue().then(function (_) { this.mk.clearQueue().then(function (_) {
if (app.mk.shuffleMode == 1){ shuffleArray(query)} if (app.mk.shuffleMode == 1) {
shuffleArray(query)
}
app.mk.queue.append(query) app.mk.queue.append(query)
if (childIndex != -1) { if (childIndex != -1) {
app.mk.changeToMediaAtIndex(childIndex) app.mk.changeToMediaAtIndex(childIndex)
@ -2395,25 +2423,30 @@ const app = new Vue({
}) })
} else { } else {
app.mk.stop().then(() => { app.mk.stop().then(() => {
if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))){ if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) {
app.mk.setQueue({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () { app.mk.setQueue({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function(){ app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function () {
if ((app.showingPlaylist && app.showingPlaylist.id == id)) { if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item)); let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
let u = query; if (app.mk.shuffleMode == 1) { shuffleArray(u) } let u = query;
if (app.mk.shuffleMode == 1) {
shuffleArray(u)
}
app.mk.queue.append(u) app.mk.queue.append(u)
} else { } else {
app.getPlaylistFromID(id, true).then(function () { app.getPlaylistFromID(id, true).then(function () {
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item)); let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
let u = query; if (app.mk.shuffleMode == 1) { shuffleArray(u) } let u = query;
if (app.mk.shuffleMode == 1) {
shuffleArray(u)
}
app.mk.queue.append(u) app.mk.queue.append(u)
}) })
} }
}) })
}) })
} } else {
else{
this.mk.setQueue({[truekind]: [id]}).then(function (queue) { this.mk.setQueue({[truekind]: [id]}).then(function (queue) {
if (item && ((queue._itemIDs[childIndex] != item.id))) { if (item && ((queue._itemIDs[childIndex] != item.id))) {
childIndex = queue._itemIDs.indexOf(item.id) childIndex = queue._itemIDs.indexOf(item.id)
@ -2428,8 +2461,10 @@ const app = new Vue({
} else { } else {
app.mk.play() app.mk.play()
} }
})} })
})} }
})
}
} catch (err) { } catch (err) {
console.log(err) console.log(err)
try { try {
@ -2541,7 +2576,11 @@ const app = new Vue({
types[index].id.push(id) types[index].id.push(id)
} }
} }
return await this.mk.api.catalogResources(types, {"omit[resource]": "autos", relate: "library", fields: "inLibrary"}) return await this.mk.api.catalogResources(types, {
"omit[resource]": "autos",
relate: "library",
fields: "inLibrary"
})
}, },
isInLibrary(playParams) { isInLibrary(playParams) {
let self = this let self = this
@ -2578,7 +2617,7 @@ const app = new Vue({
} }
}, },
getMediaItemArtwork(url, height = 64, width) { getMediaItemArtwork(url, height = 64, width) {
if(typeof url == "undefined" || url == "") { if (typeof url == "undefined" || url == "") {
return "https://beta.music.apple.com/assets/product/MissingArtworkMusic.svg" return "https://beta.music.apple.com/assets/product/MissingArtworkMusic.svg"
} }
let newurl = `${url.replace('{w}', width ?? height).replace('{h}', height).replace('{f}', "webp").replace('{c}', ((width === 900) ? "sr" : "cc"))}`; let newurl = `${url.replace('{w}', width ?? height).replace('{h}', height).replace('{f}', "webp").replace('{c}', ((width === 900) ? "sr" : "cc"))}`;
@ -2588,7 +2627,7 @@ const app = new Vue({
} }
return newurl return newurl
}, },
_rgbToRgb(rgb = [0,0,0]) { _rgbToRgb(rgb = [0, 0, 0]) {
// if rgb // if rgb
return `rgb(${rgb[0]},${rgb[1]},${rgb[2]})` return `rgb(${rgb[0]},${rgb[1]},${rgb[2]})`
}, },
@ -2608,7 +2647,7 @@ const app = new Vue({
this.currentTrackID = this.mk.nowPlayingItem["id"]; this.currentTrackID = this.mk.nowPlayingItem["id"];
document.querySelector('.bg-artwork').src = ""; document.querySelector('.bg-artwork').src = "";
if (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"]) { if (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"]) {
getBase64FromUrl(this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"].replace('{w}', size).replace('{h}', size)).then(img =>{ getBase64FromUrl(this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"].replace('{w}', size).replace('{h}', size)).then(img => {
document.querySelectorAll('.bg-artwork').forEach(artwork => { document.querySelectorAll('.bg-artwork').forEach(artwork => {
artwork.src = img; artwork.src = img;
}) })
@ -2696,29 +2735,32 @@ const app = new Vue({
// }, // },
async getCurrentArtURL(){ async getCurrentArtURL() {
try{ try {
this.currentArtUrl = ''; this.currentArtUrl = '';
if (app.mk.nowPlayingItem != null && app.mk.nowPlayingItem.attributes != null && app.mk.nowPlayingItem.attributes.artwork != null && app.mk.nowPlayingItem.attributes.artwork.url != null && app.mk.nowPlayingItem.attributes.artwork.url!= '' ) if (app.mk.nowPlayingItem != null && app.mk.nowPlayingItem.attributes != null && app.mk.nowPlayingItem.attributes.artwork != null && app.mk.nowPlayingItem.attributes.artwork.url != null && app.mk.nowPlayingItem.attributes.artwork.url != '') {
{
this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50); this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
try{ try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);} document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
catch (e) {} } catch (e) {
}
} else { } else {
let data = await this.mk.api.library.song(this.mk.nowPlayingItem.id); let data = await this.mk.api.library.song(this.mk.nowPlayingItem.id);
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) { if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) {
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50); this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
try{ try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);} document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
catch (e) {} } catch (e) {
} else {this.currentArtUrl = ''; }
try{ } else {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);} this.currentArtUrl = '';
catch (e) {} try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) {
} }
} }
}catch(e){ }
} catch (e) {
} }
}, },
@ -2743,7 +2785,7 @@ const app = new Vue({
const data = await this.mk.api.library.song(this.mk.nowPlayingItem.id) const data = await this.mk.api.library.song(this.mk.nowPlayingItem.id)
if (data != null && data !== "") { if (data != null && data !== "") {
getBase64FromUrl((data["attributes"]["artwork"]["url"]).toString()).then(img =>{ getBase64FromUrl((data["attributes"]["artwork"]["url"]).toString()).then(img => {
document.querySelector('.bg-artwork').forEach(artwork => { document.querySelector('.bg-artwork').forEach(artwork => {
artwork.src = img; artwork.src = img;
}) })
@ -2769,16 +2811,16 @@ const app = new Vue({
let type = item.type.slice(-1) === "s" ? item.type : item.type + "s" let type = item.type.slice(-1) === "s" ? item.type : item.type + "s"
let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id
if (item.id.startsWith("i.")) { if (item.id.startsWith("i.")) {
if(!type.startsWith("library-")) { if (!type.startsWith("library-")) {
type = "library-" + type type = "library-" + type
} }
id = item.id id = item.id
} }
let response = await this.mk.api.v3.music(`/v1/me/ratings/${type}?platform=web&ids=${id}`) let response = await this.mk.api.v3.music(`/v1/me/ratings/${type}?platform=web&ids=${id}`)
if(response.data.data.length != 0) { if (response.data.data.length != 0) {
let value = response.data.data[0].attributes.value let value = response.data.data[0].attributes.value
return value return value
}else{ } else {
return 0 return 0
} }
}, },
@ -2786,7 +2828,7 @@ const app = new Vue({
let type = item.type.slice(-1) === "s" ? item.type : item.type + "s" let type = item.type.slice(-1) === "s" ? item.type : item.type + "s"
let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id
if (item.id.startsWith("i.")) { if (item.id.startsWith("i.")) {
if(!type.startsWith("library-")) { if (!type.startsWith("library-")) {
type = "library-" + type type = "library-" + type
} }
id = item.id id = item.id
@ -2810,7 +2852,7 @@ const app = new Vue({
let type = item.type.slice(-1) === "s" ? item.type : item.type + "s" let type = item.type.slice(-1) === "s" ? item.type : item.type + "s"
let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id
if (item.id.startsWith("i.")) { if (item.id.startsWith("i.")) {
if(!type.startsWith("library-")) { if (!type.startsWith("library-")) {
type = "library-" + type type = "library-" + type
} }
id = item.id id = item.id
@ -2834,7 +2876,7 @@ const app = new Vue({
let type = item.type.slice(-1) === "s" ? item.type : item.type + "s" let type = item.type.slice(-1) === "s" ? item.type : item.type + "s"
let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id let id = item.attributes.playParams.catalogId ? item.attributes.playParams.catalogId : item.id
if (item.id.startsWith("i.")) { if (item.id.startsWith("i.")) {
if(!type.startsWith("library-")) { if (!type.startsWith("library-")) {
type = "library-" + type type = "library-" + type
} }
id = item.id id = item.id
@ -2848,16 +2890,20 @@ const app = new Vue({
}, },
volumeWheel(event) { volumeWheel(event) {
if (event.deltaY < 0) { if (event.deltaY < 0) {
if(this.mk.volume < 1){ if (this.mk.volume < 1) {
if (this.mk.volume <= 0.9) { if (this.mk.volume <= 0.9) {
this.mk.volume += 0.1 this.mk.volume += 0.1
} else { this.mk.volume = 1 } } else {
this.mk.volume = 1
}
} }
} else if (event.deltaY > 0) { } else if (event.deltaY > 0) {
if(this.mk.volume > 0){ if (this.mk.volume > 0) {
if (this.mk.volume >= 0.1){ if (this.mk.volume >= 0.1) {
this.mk.volume -= 0.1 this.mk.volume -= 0.1
} else {this.mk.volume = 0} } else {
this.mk.volume = 0
}
} }
} }
}, },
@ -3012,12 +3058,12 @@ const app = new Vue({
// } // }
let rating = await app.getRating(app.mk.nowPlayingItem) let rating = await app.getRating(app.mk.nowPlayingItem)
if(rating == 0) { if (rating == 0) {
menus.normal.items.find(x => x.id == 'love').disabled = false menus.normal.items.find(x => x.id == 'love').disabled = false
menus.normal.items.find(x => x.id == 'dislike').disabled = false menus.normal.items.find(x => x.id == 'dislike').disabled = false
}else if(rating == 1) { } else if (rating == 1) {
menus.normal.items.find(x => x.id == 'unlove').disabled = false menus.normal.items.find(x => x.id == 'unlove').disabled = false
}else if(rating == -1) { } else if (rating == -1) {
menus.normal.items.find(x => x.id == 'undo_dislike').disabled = false menus.normal.items.find(x => x.id == 'undo_dislike').disabled = false
} }
CiderContextMenu.Create(event, menus[useMenu]) CiderContextMenu.Create(event, menus[useMenu])
@ -3067,10 +3113,10 @@ const app = new Vue({
peak: peak peak: peak
} }
}, },
fullscreen(flag){ fullscreen(flag) {
if (flag) { if (flag) {
ipcRenderer.send('setFullScreen', true); ipcRenderer.send('setFullScreen', true);
if (app.mk.nowPlayingItem.type && app.mk.nowPlayingItem.type.toLowerCase().includes("video")){ if (app.mk.nowPlayingItem.type && app.mk.nowPlayingItem.type.toLowerCase().includes("video")) {
document.querySelector('video#apple-music-video-player').requestFullscreen() document.querySelector('video#apple-music-video-player').requestFullscreen()
} else { } else {
app.appMode = 'fullscreen'; app.appMode = 'fullscreen';
@ -3091,30 +3137,30 @@ const app = new Vue({
Vue.component('animated-number', { Vue.component('animated-number', {
template:"<div style='display: inline-block;'>{{ displayNumber }}</div>", template: "<div style='display: inline-block;'>{{ displayNumber }}</div>",
props: {'number': { default:0 }}, props: {'number': {default: 0}},
data () { data() {
return { return {
displayNumber:0, displayNumber: 0,
interval:false interval: false
} }
}, },
ready () { ready() {
this.displayNumber = this.number ? this.number : 0; this.displayNumber = this.number ? this.number : 0;
}, },
watch: { watch: {
number () { number() {
clearInterval(this.interval); clearInterval(this.interval);
if(this.number == this.displayNumber) { if (this.number == this.displayNumber) {
return; return;
} }
this.interval = window.setInterval(() => { this.interval = window.setInterval(() => {
if(this.displayNumber != this.number) { if (this.displayNumber != this.number) {
var change = (this.number - this.displayNumber) / 10; var change = (this.number - this.displayNumber) / 10;
change = change >= 0 ? Math.ceil(change) : Math.floor(change); change = change >= 0 ? Math.ceil(change) : Math.floor(change);
this.displayNumber = this.displayNumber + change; this.displayNumber = this.displayNumber + change;
@ -3246,7 +3292,7 @@ if ('serviceWorker' in navigator) {
window.addEventListener('load', () => { window.addEventListener('load', () => {
navigator.serviceWorker.register('sw.js?v=1'); navigator.serviceWorker.register('sw.js?v=1');
}); });
} }
const getBase64FromUrl = async (url) => { const getBase64FromUrl = async (url) => {
const data = await fetch(url); const data = await fetch(url);

View file

@ -138,12 +138,14 @@
let followAction = "follow" let followAction = "follow"
let followActions = { let followActions = {
follow: { follow: {
icon: "./assets/feather/plus-circle.svg",
name: "Follow Artist", name: "Follow Artist",
action: ()=>{ action: ()=>{
self.app.cfg.home.followedArtists.push(self.data.id) self.app.cfg.home.followedArtists.push(self.data.id)
} }
}, },
unfollow: { unfollow: {
icon: "./assets/feather/x-circle.svg",
name: "Unfollow Artist", name: "Unfollow Artist",
action: ()=>{ action: ()=>{
let index = self.app.cfg.home.followedArtists.indexOf(self.data.id) let index = self.app.cfg.home.followedArtists.indexOf(self.data.id)
@ -156,9 +158,11 @@
if(this.app.cfg.home.followedArtists.includes(self.data.id)) { if(this.app.cfg.home.followedArtists.includes(self.data.id)) {
followAction = "unfollow" followAction = "unfollow"
} }
CiderContextMenu.Create(event, { app.showMenuPanel({
name: self.data.attributes.name,
items: [ items: [
{ {
icon: "./assets/feather/play.svg",
name: "Play Artist Radio", name: "Play Artist Radio",
action: ()=>{ action: ()=>{
app.mk.setStationQueue({artist:self.data.id}).then(()=>{ app.mk.setStationQueue({artist:self.data.id}).then(()=>{
@ -168,6 +172,7 @@
}, },
followActions[followAction], followActions[followAction],
{ {
icon: "./assets/feather/share.svg",
name: "Share", name: "Share",
action: ()=>{ action: ()=>{
self.app.copyToClipboard(self.data.attributes.url) self.app.copyToClipboard(self.data.attributes.url)