Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
Please see below the most popular frequently asked questions.
Loading article...
Loading faqs...
Please see below the current ongoing issues which are under investigation.
Loading issue...
Loading ongoing issues...
I am using the Spotify Playback SDK on my local site. This is my code:
window.onSpotifyWebPlaybackSDKReady = () => {
const token = "<?php echo $_SESSION["accessToken"] ?>";
const player = new Spotify.Player({
name: 'Spotify Clone',
getOAuthToken: cb => {
cb(token);
}
});
window.player = player;
// Connect to the player!
window.player.connect();
// Error handling
window.player.addListener('initialization_error', ({message}) => {
console.error(message);
});
window.player.addListener('authentication_error', ({message}) => {
console.error(message);
});
window.player.addListener('account_error', ({message}) => {
console.error(message);
});
window.player.addListener('playback_error', ({message}) => {
console.error(message);
});
// Playback status updates
window.player.addListener('player_state_changed', state => {
console.log(state);
});
// Ready
window.player.addListener('ready', ({device_id}) => {
console.log('Ready with Device ID', device_id);
});
// Not Ready
window.player.addListener('not_ready', ({device_id}) => {
console.log('Device ID has gone offline', device_id);
});
}
document.getElementById("play-arrow").onclick = function () {
window.player.togglePlay().then(() => {
console.log('Toggled playback!');
});
}
Everything else is working. For example I can display the current position in the browser. Everything like togglePlay or skip or seek is only working like 10% of the time connecting to the device and I have to reload the page multiple times and connect. This is the error I get:
index.js:9 Uncaught TypeError: Cannot read property 'togglePlay' of null
at h._playbackControl (index.js:9)
at h._onTogglePlay (index.js:9)
at h._handleMessages (index.js:9)
at r._receiveMessage (index.js:9)
window.player is not Null, I checked it in the console.
Any ideas?