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: {
|
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 ?? "";
|
||||||
|
@ -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) {
|
} 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"
|
||||||
|
@ -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)) {
|
} 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({
|
||||||
|
@ -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 {
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -2400,20 +2428,25 @@ const app = new Vue({
|
||||||
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
|
||||||
|
@ -2699,23 +2738,26 @@ 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 = '';
|
}
|
||||||
|
} else {
|
||||||
|
this.currentArtUrl = '';
|
||||||
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) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -2851,13 +2893,17 @@ const app = new Vue({
|
||||||
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue