-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbasic.html
43 lines (37 loc) · 1.71 KB
/
basic.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<title>Spotify Web Playback SDK Quick Start Tutorial</title>
</head>
<body>
<h1>Spotify Web Playback SDK Quick Start Tutorial</h1>
<h2>Open your console log: <code>View > Developer > JavaScript Console</code></h2>
<script src="https://sdk.scdn.co/spotify-player.js"></script>
<script>
window.onSpotifyWebPlaybackSDKReady = () => {
const token = 'BQASdOx8yf-Ak5WhbOx-PyzDaBtIXHqcfxWm2fe_0aCwqYa9aLvOWEvdgL75-U25TgF8f59VKqDJrqFyftyKpN30Q9zO3VkVN_DM53fFIFFOsLXe1X-Isjnb_ZDiDaMMNG53tmlFyRG9sVThL8sALfCou-5-itgernjyyBj89_JJYggePkaeEPISs5yDpTewGse48lgxrLmLX4ouRJzAz5OZYxtjMOzZuSSn6FMT0Lr0y-bSvYKiP4fxecz60JQpElQEW9rjGAjkfc_yRr23F6B6LRvNfNFakOJB-0pOs4KwovJcR25_1pQw';
const player = new Spotify.Player({
name: 'Web Playback SDK Quick Start Player',
getOAuthToken: cb => { cb(token); }
});
// Error handling
player.addListener('initialization_error', ({ message }) => { console.error(message); });
player.addListener('authentication_error', ({ message }) => { console.error(message); });
player.addListener('account_error', ({ message }) => { console.error(message); });
player.addListener('playback_error', ({ message }) => { console.error(message); });
// Playback status updates
player.addListener('player_state_changed', state => { console.log(state); });
// Ready
player.addListener('ready', ({ device_id }) => {
console.log('Ready with Device ID', device_id);
});
// Not Ready
player.addListener('not_ready', ({ device_id }) => {
console.log('Device ID has gone offline', device_id);
});
// Connect to the player!
player.connect();
};
</script>
</body>
</html>