Announcements

Help Wizard

Step 1

NEXT STEP

iFrame API 'ready' never gets called

iFrame API 'ready' never gets called

I can't get the 'ready' event to be called. Anyone else is having this issue?

 

 

 

 

 

 

const onSpotifyLoaded = controller => {
	controller.addListener('ready', () => {
		console.log("Player is Ready")
	})
}

window.SpotifyIFrameAPI.createController(playerEl.current, {uri: 'xxx'}, onSpotifyLoaded)

window.onSpotifyIframeApiReady = IFrameAPI => {
	window.SpotifyIFrameAPI = IFrameAPI
}

 

 

 

 

 

 

Reply
3 Replies

It looks like the first test of that function fails:

 

onWindowMessages = (e: MessageEvent): void => {
    if (e.source === this.iframeElement.contentWindow) {
      if (e.data?.type === 'player_ready') {
        this.onPlayerReady();
      }

      if (e.data?.type === 'playback_update') {
        const playbackState = e.data?.payload;
        this.onPlaybackUpdate(playbackState);
      }
    }
  };

 

I'm getting an error in the console to using this API. It could be that I'm misunderstanding the documentation on this. Could Spotify respond?

Just to add I'm getting the message "Failed to load resource: the server responded with a status of 404 (Not Found)" when I place the following code into the file


```js

window.onSpotifyIframeApiReady = (IFrameAPI) => {
  let element = document.getElementById("embed-iframe");
  let options = {
    uri: "spotify:episode:7makk4oTQel546B0PZlDM5",
  };
  let callback = (EmbedController) => {};
  IFrameAPI.createController(element, options, callback);
};
```
console.log(window.onSpotifyIframeApiReady)

Suggested posts