🐛 (spotify)
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
content="width=device-width,initial-scale=1.0,user-scalable=no"
|
content="width=device-width,initial-scale=1.0,user-scalable=no"
|
||||||
/>
|
/>
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
|
||||||
<script src="https://sdk.scdn.co/spotify-player.js"></script>
|
|
||||||
<title>Binôme</title>
|
<title>Binôme</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ import {
|
|||||||
playOnSpotify,
|
playOnSpotify,
|
||||||
pauseOnSpotify
|
pauseOnSpotify
|
||||||
} from '@/utils/spotify'
|
} from '@/utils/spotify'
|
||||||
import { ref, reactive } from '@vue/composition-api'
|
import { ref, reactive, onMounted } from '@vue/composition-api'
|
||||||
|
|
||||||
window.onSpotifyWebPlaybackSDKReady = () => {}
|
|
||||||
|
|
||||||
export const useSpotify = (onPlay: () => void, onPause: () => void) => {
|
export const useSpotify = (onPlay: () => void, onPause: () => void) => {
|
||||||
const ready = ref(false)
|
const ready = ref(false)
|
||||||
@@ -26,6 +24,7 @@ export const useSpotify = (onPlay: () => void, onPause: () => void) => {
|
|||||||
RootActions
|
RootActions
|
||||||
>(['setAccessToken', 'setTokenExpire', 'setHasSpotify'])
|
>(['setAccessToken', 'setTokenExpire', 'setHasSpotify'])
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
window.onSpotifyWebPlaybackSDKReady = async () => {
|
window.onSpotifyWebPlaybackSDKReady = async () => {
|
||||||
if (!hasValidAccessToken.value) {
|
if (!hasValidAccessToken.value) {
|
||||||
redirectToSpotifyConnect()
|
redirectToSpotifyConnect()
|
||||||
@@ -63,6 +62,8 @@ export const useSpotify = (onPlay: () => void, onPause: () => void) => {
|
|||||||
})
|
})
|
||||||
await spotify.player.connect()
|
await spotify.player.connect()
|
||||||
}
|
}
|
||||||
|
import('@/lib/spotify-player')
|
||||||
|
})
|
||||||
|
|
||||||
const play = async () => {
|
const play = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user