mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 13:04:23 +00:00
45 lines
1.4 KiB
Vue
45 lines
1.4 KiB
Vue
<template>
|
|
<div>
|
|
<h1>AppleMusic</h1>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
devTokenAvailable: false,
|
|
musicKit: null,
|
|
}
|
|
},
|
|
methods: {
|
|
prepare() {
|
|
document.addEventListener( 'musickitloaded', function() {
|
|
fetch( 'http://localhost:8081/getAppleMusicDevToken' ).then( res => {
|
|
if ( res.status === 200 ) {
|
|
this.devTokenAvailable = true;
|
|
res.text().then( token => {
|
|
this.musicKit = MusicKit.configure({
|
|
developerToken: token,
|
|
app: {
|
|
name: 'MusicPlayer',
|
|
build: '2.1.0'
|
|
}
|
|
} );
|
|
setTimeout( () => {
|
|
this.musicKit.authorize();
|
|
}, 100 );
|
|
} );
|
|
}
|
|
} );
|
|
});
|
|
}
|
|
},
|
|
created() {
|
|
window.addEventListener( 'DOMContentLoaded', () => {
|
|
this.prepare();
|
|
} );
|
|
}
|
|
}
|
|
|
|
</script> |