ShelbyTV / shelby-gt-web

the new shelby web front end for rolls <over />
shelby.tv
3 stars 0 forks source link

Check all the players for the "playing while hidden" problems #560

Open iceberg901 opened 12 years ago

iceberg901 commented 12 years ago

We've found that some of the players sometimes keep playing when they are hidden. I am implementing fixes for Vimeo and Collegehumor. However, the issue is a fairly generic one, and we should test all of the other players for it individually and fix them if necessary. This is only an issue for players that don't get completely torn down when leave() is called on them.

The general issue is when you leave a player view and try to pause the player when the video is in a state that doesn't accept pausing. A common case here is that the player is in the middle of an asynchronous process (or buffering) that will ultimately result in it playing, but it isn't playing yet. You can't pause yet, so when you try to pause the player on leave nothing happens. Then you hide the player and later that asynchronous process returns and starts playing the hidden player.

The fix I'm using should be appropriate for all of the players, but the implementation is different in each case. The basic idea is to keep track of whether the player is the active player (a private boolean member _isActivePlayer works nicely) and then in any callback that signals that the player has started playing, if the player is not the active player, pause immediately.

iceberg901 commented 12 years ago

Another issue that I've fixed in the College Humor player, which should be checked for in all the other players, worked like this:

So the general issue is updating state in a callback to reflect conditions at the time the asynchronous method was called, when those conditions may have changed in the interim.

ckurdziel commented 11 years ago

Steps to reproduce from @reecepacheco:

1) play college humor video until the end 2) select another video in your stream (in the background, the CH video player starts loading a post-roll ad) 3) the audio of the ad will then play while you're watching the new video