Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Any way to stop the Spotify player (embed) when the user scrolls the website page?

Any way to stop the Spotify player (embed) when the user scrolls the website page?

Does anyone know of a way to stop the Spotify player (embed) when the user scrolls the website page? 

We have this code working now:

 

 

 

// Get a reference to the embed iframe element
const spotifyEmbedWindow = document.querySelector('iframe[src*="spotify.com/embed"]').contentWindow;

spotifyEmbedWindow.postMessage({command: 'toggle'}, '*');

 

 

 

 

However, if the user has manually paused the player, it will start to play when the user scrolls. 

 

Is there a way to fully STOP or PAUSE the music instead of TOGGLING?

 

Any help here is appreciated.
Erica

 

Reply
4 Replies

Hi Erica,

 

I'm an engineer working on the Spotify embed player and we have now added "pause" command to the iframe API.

Please try the following code and let us know if it works

 

spotifyEmbedWindow.postMessage({command: 'pause'}, '*');



Thanks I tried toggle and it works! Is there a full list of the commands that can be used with postMessage?

Hi,

Is this feature no longer supported?

Hi,

Is this feature no longer supported?

Suggested posts

Type a product name