Added isInLibrary(id)
This commit is contained in:
parent
0190beb5b8
commit
d1c4a4abea
2 changed files with 14 additions and 9 deletions
|
@ -129,6 +129,12 @@ const app = new Vue({
|
|||
// Set profile name
|
||||
this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "")
|
||||
|
||||
// load cached library
|
||||
if(localStorage.getItem("librarySongs") != null) {
|
||||
this.library.songs.listing = JSON.parse(localStorage.getItem("librarySongs"))
|
||||
this.library.songs.displayListing = this.library.songs.listing
|
||||
}
|
||||
|
||||
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
||||
|
||||
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
||||
|
@ -844,17 +850,12 @@ const app = new Vue({
|
|||
self.search.results = results
|
||||
})
|
||||
},
|
||||
isInLibrary() {
|
||||
isInLibrary(id) {
|
||||
let self = this
|
||||
// ugly code to check if current playback item is in library
|
||||
var found = this.library.songs.listing.filter((item)=>{
|
||||
var playingNow = "";
|
||||
if(this.mk.nowPlayingItem["attributes"]){
|
||||
if(this.mk.nowPlayingItem["attributes"]["playParams"] && this.mk.nowPlayingItem["attributes"]["playParams"]["catalogId"]){
|
||||
playingNow = this.mk.nowPlayingItem["attributes"]["playParams"]["catalogId"];
|
||||
}
|
||||
}
|
||||
if(item["attributes"]){
|
||||
if(item["attributes"]["playParams"] && item["attributes"]["playParams"]["catalogId"] == playingNow){
|
||||
if(item["attributes"]["playParams"] && (item["attributes"]["playParams"]["catalogId"] == id)){
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue