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
|
// Set profile name
|
||||||
this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "")
|
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")
|
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
||||||
|
@ -844,17 +850,12 @@ const app = new Vue({
|
||||||
self.search.results = results
|
self.search.results = results
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
isInLibrary() {
|
isInLibrary(id) {
|
||||||
|
let self = this
|
||||||
// ugly code to check if current playback item is in library
|
// ugly code to check if current playback item is in library
|
||||||
var found = this.library.songs.listing.filter((item)=>{
|
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"]){
|
||||||
if(item["attributes"]["playParams"] && item["attributes"]["playParams"]["catalogId"] == playingNow){
|
if(item["attributes"]["playParams"] && (item["attributes"]["playParams"]["catalogId"] == id)){
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,11 @@
|
||||||
:max="mk.currentPlaybackDuration" :value="playerLCD.playbackDuration">
|
:max="mk.currentPlaybackDuration" :value="playerLCD.playbackDuration">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">❤️</div>
|
<template v-if="mk.nowPlayingItem['attributes']['playParams']['id']">
|
||||||
|
<div class="actions" v-if="isInLibrary(mk.nowPlayingItem['attributes']['playParams']['id'])">❤️</div>
|
||||||
|
<div class="actions" v-else>🖤</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue