Skip to content

Commit

Permalink
Merge pull request #446 from bbc/IPLAYERTVV1-4293
Browse files Browse the repository at this point in the history
Iplayertvv1 4293
  • Loading branch information
tsadler1988 authored May 10, 2017
2 parents d5f6907 + acf6af6 commit 1788642
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions static/script-tests/tests/devices/mediaplayer/html5commontests.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ window.commonTests.mediaPlayer.html5.mixinTests = function (testCase, mediaPlaye
}
clock.restore();
clock = undefined;
},
pause: function () {
mediaEventListeners.pause();
}
};

Expand Down Expand Up @@ -591,6 +594,18 @@ window.commonTests.mediaPlayer.html5.mixinTests = function (testCase, mediaPlaye
});
};

// *********************
mixins.testPausePassedFromMediaElementToMediaPlayer = function(queue) {
expectAsserts(1);
var self = this;
runMediaPlayerTest(this, queue, function (MediaPlayer) {
getToPlaying(self, MediaPlayer);
deviceMockingHooks.pause();

assertState(self, MediaPlayer.STATE.PAUSED);
});
};

mixins.testPlayCalledOnMediaElementWhenResumeInPausedState = function(queue) {
expectAsserts(2);
var self = this;
Expand Down
11 changes: 11 additions & 0 deletions static/script/devices/mediaplayer/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ define(
this._wrapOnSourceError = function() {
self._onSourceError();
};
this._wrapOnPause = function() {
self._onPause();
};
this._mediaElement.addEventListener('canplay', this._wrapOnFinishedBuffering, false);
this._mediaElement.addEventListener('seeked', this._wrapOnFinishedBuffering, false);
this._mediaElement.addEventListener('playing', this._wrapOnFinishedBuffering, false);
Expand All @@ -88,6 +91,7 @@ define(
this._mediaElement.addEventListener('waiting', this._wrapOnDeviceBuffering, false);
this._mediaElement.addEventListener('timeupdate', this._wrapOnStatus, false);
this._mediaElement.addEventListener('loadedmetadata', this._wrapOnMetadata, false);
this._mediaElement.addEventListener('pause', this._wrapOnPause, false);

var appElement = RuntimeContext.getCurrentApplication().getRootWidget().outputElement;
device.prependChildElement(appElement, this._mediaElement);
Expand Down Expand Up @@ -375,6 +379,12 @@ define(
this._exitBuffering();
},

_onPause: function() {
if (this.getState() !== MediaPlayer.STATE.PAUSED) {
this._toPaused();
}
},

_onDeviceError: function() {
this._reportError('Media element error code: ' + this._mediaElement.error.code);
},
Expand Down Expand Up @@ -482,6 +492,7 @@ define(
this._mediaElement.removeEventListener('waiting', this._wrapOnDeviceBuffering, false);
this._mediaElement.removeEventListener('timeupdate', this._wrapOnStatus, false);
this._mediaElement.removeEventListener('loadedmetadata', this._wrapOnMetadata, false);
this._mediaElement.removeEventListener('pause', this._wrapOnPause, false);
this._sourceElement.removeEventListener('error', this._wrapOnSourceError, false);

var device = RuntimeContext.getDevice();
Expand Down

0 comments on commit 1788642

Please sign in to comment.