Skip to content

Commit

Permalink
Merge pull request #1087 from kaltura/seekAfterPreSequence
Browse files Browse the repository at this point in the history
Support seek after pre sequence
  • Loading branch information
OrenMe committed Oct 22, 2014
2 parents 4be58bd + 0a5c9c4 commit 392c320
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
18 changes: 18 additions & 0 deletions modules/AdSupport/resources/mw.AdTimeline.js
Expand Up @@ -103,6 +103,7 @@
firstPlay: true,

bindPostfix: '.AdTimeline',
pendingSeek: false,

currentAdSlotType: null,

Expand Down Expand Up @@ -169,6 +170,17 @@
// Start of preSequence
embedPlayer.triggerHelper( 'AdSupport_PreSequence');

mw.log( 'EmbedPlayer::preSeek : prevented seek during ad playback');
embedPlayer.unbindHelper("preSeek" + _this.bindPostfix).bindHelper("preSeek" + _this.bindPostfix, function(e, percentage, stopAfterSeek, stopSeek) {
embedPlayer.unbindHelper( "preSeek" + _this.bindPostfix );
stopSeek.value = true;
_this.pendingSeek = true;
_this.pendingSeekData = {
percentage: percentage,
stopAfterSeek: stopAfterSeek
};
});

//Setup a playedAnAdFlag
var playedAnAdFlag = false;
embedPlayer.bindHelper( 'AdSupport_StartAdPlayback' + _this.bindPostfix, function(){
Expand Down Expand Up @@ -433,6 +445,12 @@
return;
}
embedPlayer.restoreEventPropagation();

if (this.pendingSeek){
this.pendingSeek = false;
embedPlayer.seek(this.pendingSeekData.percentage, this.pendingSeekData.stopAfterSeek);
}

embedPlayer.enablePlayControls();
embedPlayer.seeking = false;
// restore in sequence property;
Expand Down
9 changes: 8 additions & 1 deletion modules/EmbedPlayer/resources/mw.EmbedPlayerKplayer.js
Expand Up @@ -440,6 +440,14 @@ mw.EmbedPlayerKplayer = {
return;
}
}

// Trigger preSeek event for plugins that want to store pre seek conditions.
var stopSeek = {value: false};
this.triggerHelper( 'preSeek', [percentage, stopAfterSeek, stopSeek] );
if(stopSeek.value){
return;
}

this.seeking = true;

// Save currentTime
Expand All @@ -459,7 +467,6 @@ mw.EmbedPlayerKplayer = {
if( stopAfterSeek ){
_this.hideSpinner();
_this.pause();
// _this.stopMonitor();
_this.updatePlayheadStatus();
} else {
// continue to playback ( in a non-blocking call to avoid synchronous pause event )
Expand Down
10 changes: 5 additions & 5 deletions modules/EmbedPlayer/resources/mw.EmbedPlayerNative.js
Expand Up @@ -392,10 +392,6 @@ mw.EmbedPlayerNative = {
*/
seek: function( percent, stopAfterSeek ) {
var _this = this;
if (this.sequenceProxy && this.sequenceProxy.isInSequence){
mw.log( 'EmbedPlayerNative::seek : prevented seek during ad playback');
return;
}
// bounds check
if( percent < 0 ){
percent = 0;
Expand All @@ -410,7 +406,11 @@ mw.EmbedPlayerNative = {
this.kPreSeekTime = _this.currentTime;

// Trigger preSeek event for plugins that want to store pre seek conditions.
this.triggerHelper( 'preSeek', percent );
var stopSeek = {value: false};
this.triggerHelper( 'preSeek', [percent, stopAfterSeek, stopSeek] );
if(stopSeek.value){
return;
}

this.seeking = true;
// Update the current time ( local property )
Expand Down
7 changes: 7 additions & 0 deletions modules/EmbedPlayer/resources/mw.EmbedPlayerSilverlight.js
Expand Up @@ -463,6 +463,13 @@

// Save currentTime
this.kPreSeekTime = _this.currentTime;
// Trigger preSeek event for plugins that want to store pre seek conditions.
var stopSeek = {value: false};
this.triggerHelper( 'preSeek', [percentage, stopAfterSeek, stopSeek] );
if(stopSeek.value){
return;
}

this.currentTime = ( percentage * this.duration ).toFixed( 2 ) ;

// trigger the html5 event:
Expand Down

0 comments on commit 392c320

Please sign in to comment.