-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added stopOthers similar to pauseOthers #139
Conversation
I'm not sure about this one... On desktops I see no issue, but on mobile browsers this might cause problems where the media that just started playing tried to stop the others, which is a pause(0), which attempts to set currentTime to zero... And on mobile browsers, they tend to only support a single instance at one time. Agreed, since iOS6 you can play 2 or more audio together, but you cannot play 2 videos together. I will think about it... But might maintain the pauseOthers() but add an optional parameter that you could put a 0 in to do the same as stop... Or put a pauseOthers(15) to make them all pause at 15 seconds... But that might actually be worse LOL - So hmm... |
@happyworm Purpose of stopOthers is to on-demand stop peer players on pages where there are multiple instances. For example, a bunch of preview players on a single page. e.g http://www.musicloops.com/ |
But that is what pauseOthers does. All stopOthers would do is pause the other players AND set their currentTime to zero. It is that last part that I have issues with. |
Also, that link you gave does not appear to use jPlayer. Those players were flash based - unless I missed something. |
@happyworm We wanted to get rid of the flash-based players to make it iOS friendly and that is when the requirement came up. If someone wants the pauseOthers to pause at their current state then it might cause an issue. If it is going to reset to 0 then that's fine. |
OK. I'm convinced... Consider this feature as considered. However... You may have been able to use this by adding a pause event handler via the options: pause: function() {
$(this).jPlayer("pause", 0);
} Whenever the jPlayer was paused or stopped, it would reset to the start. And if it was playing when another was started, then the pauseOther would cause it to reset to the start. I think I'll add the stopOthers command and test it on iOS with audio and video. I still have a bad feeling about that pause event handler if we were talking about video... Since once you start playing another video, the previous video kinda becomes lifeless on iOS. That is until you tell it to play again. I'll have to test and see. Cheers for the discussion and PR. |
I might even make a generic tellOthers(command) method so the existing pauseOthers() method becomes something like: pauseOthers: function() {
tellOthers("pause");
} The Then you could use the new $(this).jPlayer("tellOthers", "stop"); I'm thinking this way since I have hopes of making the volume shared across multiple instances (as an option) and this might become a useful common function that has more uses than I can imagine. OT: The problem with the shared volume is that if each instance has its own volume controls, then I see infinite loops happening... I'll have to be careful to distinguish between the one that had the volume changed and the other instances. Anywayz - wandered off topic. |
That'll be great. Cheers, |
As always, things are always more complex than we remember, but I have a nice I have been using it to issue the As for the The only thing atm that is bugging me, is the context and information available to the My current code has the function's this as the other instance's jPlayer object. For example: function() {
return this.status.srcSet;
} But now I'm wondering if we want to have easy access the jPlayer instance issuing the command's properties too... But maybe I'm over thinking the situation, and in practice it would be easy enough to pass that info into the function by using variable scope. My thoughts were along the lines of either: function(other) {
return this.options.muted && other.options.muted;
} Or: function(master) {
return master.options.muted && this.options.muted;
} I think the latter one... this applies to the other instance and they can access the instance giving the orders through the parameter if they want. |
Okay, this is now implemented and the commit in [dev] was tagged with this PR number. See above. So the play: function() { // Stop other jPlayer instances
$(this).jPlayer("pauseOthers", 0);
} Or you can do it like this if you do not care about media errors, or if you setMedia on all your players to something: play: function() { // Stop other jPlayer instances
$(this).jPlayer("tellOthers", "stop");
} Or if you do care: play: function() { // Stop other jPlayer instances
$(this).jPlayer("tellOthers", "stop", function() {
return this.status.srcSet;
});
} |
Release notes (the actual page has links and stuff):
Closing this issue. |
Thank you. |
No description provided.