cleaned up a bit, added fetch playlist function
This commit is contained in:
parent
9978a7e8c2
commit
90670206ba
2 changed files with 13 additions and 5 deletions
|
@ -140,7 +140,7 @@
|
||||||
<div class="app-sidebar-header-text">
|
<div class="app-sidebar-header-text">
|
||||||
Playlists
|
Playlists
|
||||||
</div>
|
</div>
|
||||||
<button class="app-sidebar-item" v-for="item in playlists.items" :key="item.id" href="">
|
<button class="app-sidebar-item" v-for="item in playlists.listing" :key="item.id" href="item.href">
|
||||||
{{ item.attributes.name }}
|
{{ item.attributes.name }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,7 +44,8 @@ const app = new Vue({
|
||||||
playbackDuration: 0
|
playbackDuration: 0
|
||||||
},
|
},
|
||||||
playlists: {
|
playlists: {
|
||||||
items: []
|
listing: [],
|
||||||
|
details: {}
|
||||||
},
|
},
|
||||||
page: "browse"
|
page: "browse"
|
||||||
},
|
},
|
||||||
|
@ -54,14 +55,13 @@ const app = new Vue({
|
||||||
this.mk = MusicKit.getInstance()
|
this.mk = MusicKit.getInstance()
|
||||||
this.mk.authorize()
|
this.mk.authorize()
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a)=>{
|
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a)=>{
|
||||||
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)
|
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.apiCall('https://api.music.apple.com/v1/me/library/playlists', res => {
|
this.apiCall('https://api.music.apple.com/v1/me/library/playlists', res => {
|
||||||
console.log(res.data)
|
self.playlists.listing = res.data
|
||||||
console.log(res.data.length)
|
|
||||||
self.playlists.items = res.data
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
unauthorize() {
|
unauthorize() {
|
||||||
|
@ -136,6 +136,14 @@ const app = new Vue({
|
||||||
xmlHttp.setRequestHeader("Content-Type", "application/json");
|
xmlHttp.setRequestHeader("Content-Type", "application/json");
|
||||||
xmlHttp.responseType = "text";
|
xmlHttp.responseType = "text";
|
||||||
xmlHttp.send();
|
xmlHttp.send();
|
||||||
|
},
|
||||||
|
fetchPlaylist(id, callback) {
|
||||||
|
// id can be found in playlist.attributes.playParams.globalId
|
||||||
|
this.mk.api.playlist(id).then(res => {
|
||||||
|
callback(res)
|
||||||
|
})
|
||||||
|
|
||||||
|
// tracks are found in relationship.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue