added app.openAppleMusicURL(url) function
This commit is contained in:
parent
a5a8a09d04
commit
12be6212e8
2 changed files with 242 additions and 191 deletions
|
@ -322,6 +322,21 @@ const app = new Vue({
|
|||
},
|
||||
},
|
||||
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) {
|
||||
app.menuPanel.visible = true;
|
||||
app.menuPanel.content.name = data.name ?? "";
|
||||
|
@ -391,7 +406,9 @@ const app = new Vue({
|
|||
} else if ((self.selectedMediaItems[i].kind == "album" || self.selectedMediaItems[i].kind == "albums") && self.selectedMediaItems[i].isLibrary != true) {
|
||||
self.selectedMediaItems[i].kind = "albums"
|
||||
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)
|
||||
} else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") {
|
||||
self.selectedMediaItems[i].kind = "library-songs"
|
||||
|
@ -402,7 +419,9 @@ const app = new Vue({
|
|||
} 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"
|
||||
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)
|
||||
} else {
|
||||
pl_items.push({
|
||||
|
@ -892,7 +911,9 @@ const app = new Vue({
|
|||
"fields[catalog]": "artistUrl,albumUrl",
|
||||
"fields[songs]": "artistUrl,albumUrl"
|
||||
}
|
||||
if (!transient) {this.playlists.loadingState = 0;}
|
||||
if (!transient) {
|
||||
this.playlists.loadingState = 0;
|
||||
}
|
||||
let playlistId = ''
|
||||
|
||||
try {
|
||||
|
@ -1560,6 +1581,7 @@ const app = new Vue({
|
|||
this.library.songs.downloadState = 1
|
||||
this.library.downloadNotification.show = true
|
||||
this.library.downloadNotification.message = "Updating library songs..."
|
||||
|
||||
function downloadChunk() {
|
||||
const params = {
|
||||
"include[library-songs]": "catalog,artists,albums",
|
||||
|
@ -1580,7 +1602,8 @@ const app = new Vue({
|
|||
if (downloaded.next != null && typeof downloaded.next === "function") {
|
||||
downloaded.next("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
}) } else {
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
}
|
||||
}
|
||||
|
@ -1659,7 +1682,8 @@ const app = new Vue({
|
|||
if (downloaded.next != null && typeof downloaded.next === "function") {
|
||||
downloaded.next("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
}) } else {
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
}
|
||||
}
|
||||
|
@ -1739,7 +1763,8 @@ const app = new Vue({
|
|||
if (downloaded.next != null && typeof downloaded.next === "function") {
|
||||
downloaded.next("", "artists", {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
}) } else {
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
}
|
||||
|
||||
|
@ -2362,6 +2387,7 @@ const app = new Vue({
|
|||
array[j] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
let kind = parent.substring(0, parent.indexOf(":"))
|
||||
let id = parent.substring(parent.indexOf(":") + 1, parent.length)
|
||||
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
|
@ -2379,7 +2405,9 @@ const app = new Vue({
|
|||
|
||||
app.mk.stop().then(() => {
|
||||
this.mk.clearQueue().then(function (_) {
|
||||
if (app.mk.shuffleMode == 1){ shuffleArray(query)}
|
||||
if (app.mk.shuffleMode == 1) {
|
||||
shuffleArray(query)
|
||||
}
|
||||
app.mk.queue.append(query)
|
||||
if (childIndex != -1) {
|
||||
app.mk.changeToMediaAtIndex(childIndex)
|
||||
|
@ -2400,20 +2428,25 @@ const app = new Vue({
|
|||
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function () {
|
||||
if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
|
||||
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)
|
||||
} else {
|
||||
app.getPlaylistFromID(id, true).then(function () {
|
||||
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)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
this.mk.setQueue({[truekind]: [id]}).then(function (queue) {
|
||||
if (item && ((queue._itemIDs[childIndex] != item.id))) {
|
||||
childIndex = queue._itemIDs.indexOf(item.id)
|
||||
|
@ -2428,8 +2461,10 @@ const app = new Vue({
|
|||
} else {
|
||||
app.mk.play()
|
||||
}
|
||||
})}
|
||||
})}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
try {
|
||||
|
@ -2541,7 +2576,11 @@ const app = new Vue({
|
|||
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) {
|
||||
let self = this
|
||||
|
@ -2699,23 +2738,26 @@ const app = new Vue({
|
|||
async getCurrentArtURL() {
|
||||
try {
|
||||
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);
|
||||
try {
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);}
|
||||
catch (e) {}
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
|
||||
} catch (e) {
|
||||
}
|
||||
} else {
|
||||
let data = await this.mk.api.library.song(this.mk.nowPlayingItem.id);
|
||||
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) {
|
||||
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
|
||||
try {
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);}
|
||||
catch (e) {}
|
||||
} else {this.currentArtUrl = '';
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
|
||||
} catch (e) {
|
||||
}
|
||||
} else {
|
||||
this.currentArtUrl = '';
|
||||
try {
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);}
|
||||
catch (e) {}
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -2851,13 +2893,17 @@ const app = new Vue({
|
|||
if (this.mk.volume < 1) {
|
||||
if (this.mk.volume <= 0.9) {
|
||||
this.mk.volume += 0.1
|
||||
} else { this.mk.volume = 1 }
|
||||
} else {
|
||||
this.mk.volume = 1
|
||||
}
|
||||
}
|
||||
} else if (event.deltaY > 0) {
|
||||
if (this.mk.volume > 0) {
|
||||
if (this.mk.volume >= 0.1) {
|
||||
this.mk.volume -= 0.1
|
||||
} else {this.mk.volume = 0}
|
||||
} else {
|
||||
this.mk.volume = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -138,12 +138,14 @@
|
|||
let followAction = "follow"
|
||||
let followActions = {
|
||||
follow: {
|
||||
icon: "./assets/feather/plus-circle.svg",
|
||||
name: "Follow Artist",
|
||||
action: ()=>{
|
||||
self.app.cfg.home.followedArtists.push(self.data.id)
|
||||
}
|
||||
},
|
||||
unfollow: {
|
||||
icon: "./assets/feather/x-circle.svg",
|
||||
name: "Unfollow Artist",
|
||||
action: ()=>{
|
||||
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)) {
|
||||
followAction = "unfollow"
|
||||
}
|
||||
CiderContextMenu.Create(event, {
|
||||
app.showMenuPanel({
|
||||
name: self.data.attributes.name,
|
||||
items: [
|
||||
{
|
||||
icon: "./assets/feather/play.svg",
|
||||
name: "Play Artist Radio",
|
||||
action: ()=>{
|
||||
app.mk.setStationQueue({artist:self.data.id}).then(()=>{
|
||||
|
@ -168,6 +172,7 @@
|
|||
},
|
||||
followActions[followAction],
|
||||
{
|
||||
icon: "./assets/feather/share.svg",
|
||||
name: "Share",
|
||||
action: ()=>{
|
||||
self.app.copyToClipboard(self.data.attributes.url)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue