Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:22:35+00:00 2026-06-13T04:22:35+00:00

SoundCloud players have a default functionality where when a user starts a player, it

  • 0

SoundCloud players have a default functionality where when a user starts a player, it automatically pauses all others that are currently playing. (example: http://jsfiddle.net/Vx6hM/).

I’m trying to recreate this with embedded youtube videos that are added dynamically via the normal embed code.

Using this: https://stackoverflow.com/a/7513356/938089
and this: https://stackoverflow.com/a/7988536/1470827

I’m able to get this far:

function chain(){

$('.post').each(function(){
    var player_id = $(this).children('iframe').attr("id");
    var other_player_id = $(this).siblings().children('iframe').attr("id");

    player = new YT.Player( player_id, { 

        events:
            {      
            'onStateChange': function (event) 
                {

                if (event.data == YT.PlayerState.PLAYING) 
                    { callPlayer( other_player_id , 'pauseVideo' );
                     alert('Trying to pause: ' + other_player_id);
                    }            

                }
            }        
    });

});

}

Here’s a JS Bin with it half working: http://jsbin.com/oxoyes/2/edit

Currently, its only calling one of the players. I need it to pause ALL of the other players except the playing one.

Also, any tips on how to clean this up and/or do it differently/better are welcome. I’m still very new to javascript so I’m not even sure I’m going about it the right way.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:22:37+00:00Added an answer on June 13, 2026 at 4:22 am

    You’ll only have at most one player playing at a given time. Instead of trying to pause all that are playing, think of it as trying to pause the one playing. Of course, none could be playing. Given this, take a look at the following code. You maintain a single outer scope variable and pause that when necessary, while setting it to the player you just started playing thereafter.

    var playerCurrentlyPlaying = null;
    function chain(){       
        $('.post').each(function(){
            var player_id = $(this).children('iframe').attr("id");
            player = new YT.Player( player_id, { 
                events:
                    {      
                    'onStateChange': function (event) 
                        {
    
                        if (event.data == YT.PlayerState.PLAYING) 
                            { 
                              if(playerCurrentlyPlaying != null && 
                              playerCurrentlyPlaying != player_id)
                              callPlayer( playerCurrentlyPlaying , 'pauseVideo' );
                              playerCurrentlyPlaying = player_id;
    
                            }            
    
                        }
                    }        
            });
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you pause the Soundcloud Custom Player ( http://developers.soundcloud.com/docs/custom-player )? I have a
I have got three screenshots below of Flash-based audio players on various websites that
I'm looking to add previous and next buttons to the SoundCloud custom player, which
I'm trying to set up the SC html 5 api located here: http://w.soundcloud.com/player/api.js However
From: http://developers.soundcloud.com/docs/api/tracks#filtering I'm not sure from the docs if this functionality is available. I
Example: http://soundcloud.com/torsmusic/emancipator-siren-tor-remix You will notice that if you click play, the favicon dynamically displays
I've got a flash player (using JWPlayer) that plays an audio file. The file
I'm having an issue with a custom soundcloud button that I want to add
My custom player at woofdriver.com only shows the first 50 of my SoundCloud account's
I'm using the soundcloud plugin and by default it displays the tracklist. What I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.