Skip to content

Commit 917eded

Browse files
committed
Updated readme to include proper use
1 parent 048e69c commit 917eded

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,33 @@ export default defineNuxtConfig({
4040
})
4141
```
4242

43-
3. Use the `useMusicKit` composable in your components:
43+
3. Use the `useMusicKit` composable with proper initialization:
4444

4545
```vue
4646
<script setup>
47-
const { musicKit, isAuthorized } = useMusicKit()
47+
const { getInstance, musicKitConnected, tokenExpired } = useMusicKit()
4848
4949
async function playSong() {
50-
await musicKit.setQueue({ song: '123456789' })
51-
await musicKit.play()
50+
const musicKit = await getInstance()
51+
if (musicKit) {
52+
await musicKit.setQueue({ song: '123456789' })
53+
await musicKit.play()
54+
}
5255
}
5356
</script>
5457
5558
<template>
56-
<button @click="playSong" :disabled="!isAuthorized">
59+
<button @click="playSong" :disabled="!musicKitConnected || tokenExpired">
5760
Play Song
5861
</button>
5962
</template>
6063
```
6164

65+
**Available Composables:**
66+
- `getInstance(): Promise<MusicKitInstance>` - Initialize and get MusicKit instance
67+
- `musicKitConnected: Ref<boolean>` - Connection status
68+
- `tokenExpired: Ref<boolean>` - Dev token expiration state
69+
6270
## Obtaining MusicKit Credentials
6371

6472
To use this module, you'll need to create a MusicKit key in your Apple Developer account:

0 commit comments

Comments
 (0)