Spotify iFrame API has two play state management methods. These are play() and togglePlay(). I want to after the listen any trigger, initialize and play automatically the player. But these methods not working. (destory() method working correctly.)
My code snippet:
<script src="https://open.spotify.com/embed-podcast/iframe-api/v1" async></script>
<div id="embed-iframe"></div>
<script>
window.onSpotifyIframeApiReady = (IFrameAPI) => {
let element = document.getElementById('embed-iframe');
let options = {
uri: 'spotify:episode:7makk4oTQel546B0PZlDM5'
};
let callback = (EmbedController) => {
document.addEventListener('click', () => {
EmbedController.play();
});
};
IFrameAPI.createController(element, options, callback);
};
</script>
The snippet was render a spotify player. But my click listener is run and EmbedController.play(); not work.