Skip to content

Commit

Permalink
[#3451] Properly play again if media with greater duration added whil…
Browse files Browse the repository at this point in the history
…e playing
  • Loading branch information
ScottDowne committed Apr 2, 2013
1 parent e1d4856 commit de65cc3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions public/src/editor/media-gallery-editor.js
Expand Up @@ -148,6 +148,7 @@ define( [ "util/lang", "util/uri", "util/keys", "util/mediatypes", "editor/edito
function addEvent() {
var start = _butter.currentTime,
end = start + data.duration,
playWhenReady = false,
trackEvent;

function addTrackEvent() {
Expand All @@ -168,9 +169,13 @@ define( [ "util/lang", "util/uri", "util/keys", "util/mediatypes", "editor/edito
if ( end > _media.duration ) {
_butter.listen( "mediaready", function onMediaReady() {
_butter.unlisten( "mediaready", onMediaReady );
if ( playWhenReady ) {
_media.play();
}
addTrackEvent();
});

playWhenReady = !_media.paused;
setBaseDuration( end );
} else {
addTrackEvent();
Expand Down
3 changes: 3 additions & 0 deletions public/src/editor/sequencer-editor.js
Expand Up @@ -172,6 +172,9 @@ define( [ "util/mediatypes", "editor/editor", "util/time",
}

function updateTrackEvent( options ) {
if ( !_butter.currentMedia.paused ) {
_butter.currentMedia.pause();
}
// If the end time is greater than the duration of the video, expand it to fit.
// We have to set an event listener on "mediaready" to update the trackevent after the base duration has been changed
if ( options.end && options.end > _butter.duration ) {
Expand Down
Expand Up @@ -88,6 +88,9 @@
clearTimeout( options.loadTimeout );
// If teardown was hit before ready, ensure we teardown.
if ( options._cancelLoad ) {
if ( options.playWhenReady ) {
_this.play();
}
options._cancelLoad = false;
options.tearDown();
}
Expand Down

0 comments on commit de65cc3

Please sign in to comment.