spotify / spotify-web-api-ts-sdk

A Typescript SDK for the Spotify Web API with types for returned data.
Other
376 stars 76 forks source link

onSpotifyWebPlaybackSDKReady is not defined #94

Open cpurev opened 12 months ago

cpurev commented 12 months ago

In official Spotify API documents there is Web Playback sdk that uses window.onSpotifyWebPlaybackSDKReady.

I tried mimicking the example but cannot quite get it working in my Next/React application. I'm wondering how would I be able to set my application as a media player? It seems that my application does not have device_id thus I cannot use all the Player endpoints.

I'm new to this. Thank you so much!

fostertheweb commented 11 months ago

You can install @types/spotify-web-playback-sdk and it will be much more pleasant to work with the playback SDK. You would need to listen for the ready event on your player instance:

player.addListener('ready', ({ device_id }) => {
  console.log('Ready with Device ID', device_id);
});

This is a snippet from the documentation here.

inanc-can commented 3 months ago

@fostertheweb Does your respond supposed to answer my question at #124 ?