some progress on player + playlist loading

This commit is contained in:
2024-06-25 11:45:11 +02:00
parent 56a714ab9e
commit 1ffdc873a7
10 changed files with 468 additions and 58 deletions

View File

@@ -1,10 +1,18 @@
<template>
<div>
<h1>Library</h1>
<playlistsView></playlistsView>
<playlistsView :playlists="$props.playlists"></playlistsView>
</div>
</template>
<script setup lang="ts">
import playlistsView from '@/components/playlistsView.vue';
defineProps( {
'playlists': {
'default': [],
'type': Array<any>,
'required': true,
}
} );
</script>

View File

@@ -29,7 +29,7 @@
import { ref } from 'vue';
import playlistView from '@/components/playlistView.vue';
import MusicKitJSWrapper from '@/scripts/player';
import MusicKitJSWrapper from '@/scripts/music-player';
const isPlaying = ref( false );
const repeatMode = ref( '' );
@@ -46,9 +46,9 @@
isPlaying.value = !isPlaying.value;
// TODO: Execute function on player
if ( isPlaying.value ) {
player.play();
player.control( 'play' );
} else {
player.pause();
player.control( 'pause' );
}
}
@@ -85,8 +85,28 @@
}
}
const getPlaylists = ( cb: ( data: object ) => void ) => {
player.getUserPlaylists( cb );
}
const logIntoAppleMusic = () => {
player.logIn();
}
const getAuth = (): boolean[] => {
return player.getAuth();
}
const skipLogin = () => {
player.init();
}
defineExpose( {
logIntoAppleMusic,
getPlaylists,
controlUI,
getAuth,
skipLogin,
} );
</script>

View File

@@ -1,5 +1,18 @@
<template>
<div>
<h3>Your playlists</h3>
<div v-for="pl in $props.playlists" v-bind:key="pl.id">
{{ pl.attributes.name }}
</div>
</div>
</template>
</template>
<script setup lang="ts">
const props = defineProps( {
'playlists': {
'default': [],
'type': Array<any>,
'required': true,
}
} )
</script>