bigscreen-player
Advanced tools
Comparing version 2.11.0 to 2.12.0
@@ -122,3 +122,4 @@ define([ | ||
// https://reference.dashif.org/dash.js/v2.9.2/samples/dash-if-reference-player/index.htm | ||
url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd' | ||
url: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd', | ||
cdn: 'dash.akamaized.net' | ||
} | ||
@@ -125,0 +126,0 @@ ] |
{ | ||
"name": "bigscreen-player", | ||
"version": "2.11.0", | ||
"version": "2.12.0", | ||
"description": "Simplified media playback for bigscreen devices.", | ||
@@ -5,0 +5,0 @@ "main": "script/bigscreenplayer.js", |
@@ -12,2 +12,16 @@ require( | ||
var recentEvents; | ||
function eventCallbackReporter (event) { | ||
recentEvents.push(event.type); | ||
} | ||
var config = { | ||
streaming: { | ||
overrides: { | ||
forceBeginPlaybackToEndOfWindow: true | ||
} | ||
} | ||
}; | ||
beforeEach(function () { | ||
@@ -24,3 +38,6 @@ jasmine.clock().install(); | ||
player = CehtmlMediaPlayer(); | ||
recentEvents = []; | ||
player = CehtmlMediaPlayer(config); | ||
player.addEventCallback(this, eventCallbackReporter); | ||
player.initialiseMedia(MediaPlayerBase.TYPE.VIDEO, 'testUrl', 'testMimeType', sourceContainer, {}); | ||
@@ -33,2 +50,91 @@ }); | ||
describe('Seek attempted and finished events', function () { | ||
it('Seek Attempted Event Emitted On Initialise Media If The State Is Empty', function () { | ||
expect(recentEvents).toContain(MediaPlayerBase.EVENT.SEEK_ATTEMPTED); | ||
}); | ||
it('Seek Finished Event Emitted On Status Update When Time is Within Sentinel Threshold And The State is Playing', function () { | ||
expect(recentEvents).toContain(MediaPlayerBase.EVENT.SEEK_ATTEMPTED); | ||
player.beginPlaybackFrom(0); | ||
mockMediaElement.playState = 4; // BUFFERING | ||
mockMediaElement.onPlayStateChange(); | ||
mockMediaElement.playState = 1; // PLAYING | ||
mockMediaElement.onPlayStateChange(); | ||
mockMediaElement.playPosition = 0; | ||
for (var i = 0; i < 6; i++) { | ||
mockMediaElement.playPosition += 500; | ||
jasmine.clock().tick(500); | ||
} | ||
expect(recentEvents).toContain(MediaPlayerBase.EVENT.SEEK_FINISHED); | ||
}); | ||
it('Seek Finished Event Is Emitted Only Once', function () { | ||
player.beginPlaybackFrom(0); | ||
mockMediaElement.playState = 4; // BUFFERING | ||
mockMediaElement.onPlayStateChange(); | ||
mockMediaElement.playState = 1; // PLAYING | ||
mockMediaElement.onPlayStateChange(); | ||
mockMediaElement.playPosition = 0; | ||
for (var i = 0; i < 6; i++) { | ||
mockMediaElement.playPosition += 500; | ||
jasmine.clock().tick(500); | ||
} | ||
expect(recentEvents).toContain(MediaPlayerBase.EVENT.SEEK_FINISHED); | ||
recentEvents = []; | ||
mockMediaElement.playPosition += 500; | ||
jasmine.clock().tick(500); | ||
expect(recentEvents).not.toContain(MediaPlayerBase.EVENT.SEEK_FINISHED); | ||
}); | ||
it('Seek Finished Event Is Emitted After restartTimeout When Enabled', function () { | ||
var restartTimeoutConfig = { | ||
streaming: { | ||
overrides: { | ||
forceBeginPlaybackToEndOfWindow: true | ||
} | ||
}, | ||
restartTimeout: 10000 | ||
}; | ||
player = CehtmlMediaPlayer(restartTimeoutConfig); | ||
player.addEventCallback(this, eventCallbackReporter); | ||
player.initialiseMedia(MediaPlayerBase.TYPE.VIDEO, 'testUrl', 'testMimeType', sourceContainer, {}); | ||
expect(recentEvents).toContain(MediaPlayerBase.EVENT.SEEK_ATTEMPTED); | ||
player.beginPlaybackFrom(0); | ||
mockMediaElement.playState = 4; // BUFFERING | ||
mockMediaElement.onPlayStateChange(); | ||
mockMediaElement.playState = 1; // PLAYING | ||
mockMediaElement.onPlayStateChange(); | ||
mockMediaElement.playPosition = 0; | ||
var numberOfLoops = 10000 / 500; | ||
for (var i = 0; i < numberOfLoops - 1; i++) { | ||
mockMediaElement.playPosition += 500; | ||
jasmine.clock().tick(500); | ||
expect(recentEvents).not.toContain(MediaPlayerBase.EVENT.SEEK_FINISHED); | ||
} | ||
mockMediaElement.playPosition += 1000; | ||
jasmine.clock().tick(1000); | ||
expect(recentEvents).toContain(MediaPlayerBase.EVENT.SEEK_FINISHED); | ||
}); | ||
}); | ||
describe('addEventCallback', function () { | ||
@@ -35,0 +141,0 @@ it('should call the callback on update', function () { |
@@ -21,3 +21,3 @@ define( | ||
return function () { | ||
return function (deviceConfig) { | ||
var eventCallbacks = []; | ||
@@ -37,2 +37,5 @@ var state = MediaPlayerBase.STATE.EMPTY; | ||
var postBufferingState; | ||
var seekFinished; | ||
var count; | ||
var timeoutHappened; | ||
@@ -168,2 +171,4 @@ var disableSentinels; | ||
emitSeekAttempted(); | ||
if (getState() === MediaPlayerBase.STATE.EMPTY) { | ||
@@ -414,2 +419,38 @@ timeAtLastSentinelInterval = 0; | ||
function emitSeekAttempted () { | ||
if (getState() === MediaPlayerBase.STATE.EMPTY) { | ||
emitEvent(MediaPlayerBase.EVENT.SEEK_ATTEMPTED); | ||
seekFinished = false; | ||
} | ||
count = 0; | ||
timeoutHappened = false; | ||
if (deviceConfig.restartTimeout) { | ||
setTimeout(function () { | ||
timeoutHappened = true; | ||
}, deviceConfig.restartTimeout); | ||
} else { | ||
timeoutHappened = true; | ||
} | ||
} | ||
function emitSeekFinishedAtCorrectStartingPoint () { | ||
var isAtCorrectStartingPoint = Math.abs(getCurrentTime() - sentinelSeekTime) <= seekSentinelTolerance; | ||
if (sentinelSeekTime === undefined) { | ||
isAtCorrectStartingPoint = true; | ||
} | ||
var isPlayingAtCorrectTime = getState() === MediaPlayerBase.STATE.PLAYING && isAtCorrectStartingPoint; | ||
if (isPlayingAtCorrectTime && count >= 5 && timeoutHappened && !seekFinished) { | ||
emitEvent(MediaPlayerBase.EVENT.SEEK_FINISHED); | ||
seekFinished = true; | ||
} else if (isPlayingAtCorrectTime) { | ||
count++; | ||
} else { | ||
count = 0; | ||
} | ||
} | ||
function onStatus () { | ||
@@ -419,2 +460,4 @@ if (getState() === MediaPlayerBase.STATE.PLAYING) { | ||
} | ||
emitSeekFinishedAtCorrectStartingPoint(); | ||
} | ||
@@ -421,0 +464,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7615817
98
69593