Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple players playing simultaneously #285

Closed
ghost opened this issue Oct 31, 2011 · 5 comments
Closed

Multiple players playing simultaneously #285

ghost opened this issue Oct 31, 2011 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Oct 31, 2011

Hi,
thanks for the great plugin. However, I have a small problem.
I have several video elements on the same page. If I click play on one video and then click play on another and so on, all videos are playing simultaneously. How can I automatically pause current player if another one is clicked?

Thanks!

@mtomasz
Copy link

mtomasz commented Nov 10, 2011

I have same problem and looking for solution too. Any ideas?

@johndyer
Copy link
Collaborator

This might be a nice feature to implement. Anyone want to take it on?

@ecurtis
Copy link

ecurtis commented Nov 21, 2011

I found the basis for this on stackoverflow and hacked it until it worked:

/ make an array for the mediaelement players
mediaElementPlayers = new Array();

jQuery('audio,video').mediaelementplayer(
{
    audioWidth: 25,
    audioHeight: 25,
    startVolume: 0.8,
    features: ['playpause'],
    success: function (mediaElement, domObject) {

          // add this mediaelement to the mediaElementPlayers array
          mediaElementPlayers.push(mediaElement);

          // bind the play event to the pauseAllPlayers function
          mediaElement.addEventListener('play', function(e) {
              pauseAllPlayers(e.target); }, false); }
});



// iterate through the mediaElementPlayers array, pause all players except the one that triggered the event.
function pauseAllPlayers(currentPlayer){
for(i=0; i<mediaElementPlayers.length; i++){
    if(mediaElementPlayers[i] != currentPlayer){
        mediaElementPlayers[i].pause();
    }
}
}

@johndyer
Copy link
Collaborator

johndyer commented Dec 6, 2011

This will be in 2.4.2

@johndyer johndyer closed this as completed Dec 6, 2011
@freeyland
Copy link

Hi, I want to be able to play all players at the same time. I want to create an app where you can select which hls stream I want to display on the screen.
How can I play multiple HLS streams on the same page?

Rgds,
F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants