bigscreen-player
Advanced tools
Comparing version 1.5.0 to 2.0.0
@@ -26,5 +26,5 @@ define([ | ||
// Toggle on screen playback controls | ||
function toggleControls() { | ||
function toggleControls () { | ||
controlsElement.style.display = controlsElement.style.display == "none" ? "block" : "none"; | ||
if(controlsElement.style.display === "block") { | ||
if (controlsElement.style.display === "block") { | ||
playButton.focus(); | ||
@@ -35,7 +35,7 @@ } | ||
// Timeout feature for controls | ||
function startControlsTimeOut() { | ||
function startControlsTimeOut () { | ||
clearTimeout(controlsTimeout); | ||
if(controlsElement.style.display === "block") { | ||
if (controlsElement.style.display === "block") { | ||
controlsTimeout = setTimeout(function () { | ||
@@ -49,6 +49,6 @@ toggleControls(); | ||
// Create event listeners | ||
// Create event listeners | ||
function setupControls () { | ||
window.addEventListener('keydown', function() { | ||
window.addEventListener('keydown', function () { | ||
startControlsTimeOut(); | ||
@@ -100,3 +100,3 @@ }); | ||
} | ||
if(state === 'WAITING') { | ||
if (state === 'WAITING') { | ||
playbackElement.appendChild(playbackSpinner); | ||
@@ -124,5 +124,5 @@ } else { | ||
{ | ||
// Content from DASH IF testing assests (used in their reference player) | ||
// Content from DASH IF testing assests (used in their reference player) | ||
// 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' | ||
} | ||
@@ -135,3 +135,2 @@ ] | ||
var windowType = WindowTypes.STATIC; | ||
var liveSupport = 'seekable'; | ||
var enableSubtitles = false; | ||
@@ -141,5 +140,5 @@ | ||
// At this point TAL environment can be injected, if needed | ||
bigscreenPlayer.init(playbackElement, minimalData, windowType, enableSubtitles, liveSupport); | ||
bigscreenPlayer.init(playbackElement, minimalData, windowType, enableSubtitles); | ||
} | ||
); |
{ | ||
"name": "bigscreen-player", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"description": "Simplified media playback for bigscreen devices.", | ||
@@ -35,2 +35,3 @@ "main": "script/bigscreenplayer.js", | ||
"requirejs": "2.0.0", | ||
"sinon": "^7.3.2", | ||
"squirejs": "0.2.1" | ||
@@ -37,0 +38,0 @@ }, |
@@ -35,3 +35,3 @@ # Bigscreen Player | ||
function (BigscreenPlayer, WindowType, LiveSupport, MediaKind) { | ||
function (BigscreenPlayer, WindowType, MediaKind) { | ||
@@ -86,7 +86,5 @@ // configure the media player that will be used before loading | ||
var windowType = WindowType.STATIC; | ||
// 'seekable', 'restartable', 'playable' | ||
var liveSupport = 'seekable'; | ||
var enableSubtitles = false; | ||
bigscreenPlayer.init(playbackElement, optionalData, windowType, enableSubtitles, liveSupport); | ||
bigscreenPlayer.init(playbackElement, optionalData, windowType, enableSubtitles); | ||
} | ||
@@ -93,0 +91,0 @@ ) |
@@ -8,11 +8,7 @@ require( | ||
'bigscreenplayer/pluginenums', | ||
'bigscreenplayer/plugins' | ||
'bigscreenplayer/plugins', | ||
'bigscreenplayer/models/transferformats', | ||
'bigscreenplayer/models/livesupport' | ||
], | ||
function (Squire, MediaState, WindowTypes, PauseTriggers, PluginEnums, Plugins) { | ||
var MediaPlayerLiveSupport = { | ||
NONE: 'none', | ||
PLAYABLE: 'playable', | ||
RESTARTABLE: 'restartable', | ||
SEEKABLE: 'seekable' | ||
}; | ||
function (Squire, MediaState, WindowTypes, PauseTriggers, PluginEnums, Plugins, TransferFormats, LiveSupport) { | ||
var injector = new Squire(); | ||
@@ -22,3 +18,8 @@ var bigscreenPlayer; | ||
var playbackElement; | ||
var manifestParserMock; | ||
var manifestData; | ||
var liveSupport; | ||
var forceManifestLoadError; | ||
var successCallback = jasmine.createSpy('successCallback'); | ||
var errorCallback = jasmine.createSpy('errorCallback'); | ||
var noCallbacks = false; | ||
@@ -35,2 +36,27 @@ var mockEventHook; | ||
mockPlayerComponent.getLiveSupport = function () { | ||
return liveSupport; | ||
}; | ||
function setupManifestData (options) { | ||
manifestData = { | ||
transferFormat: options && options.transferFormat || 'dash', | ||
time: options && options.time || { | ||
windowStartTime: 724000, | ||
windowEndTime: 4324000, | ||
correction: 0 | ||
} | ||
}; | ||
} | ||
var manifestLoaderMock = { | ||
load: function (urls, serverDate, callbacks) { | ||
if (forceManifestLoadError) { | ||
callbacks.onError(); | ||
} else { | ||
callbacks.onSuccess(manifestData); | ||
} | ||
} | ||
}; | ||
function initialiseBigscreenPlayer (options) { | ||
@@ -41,3 +67,2 @@ // options = subtitlesAvailable, windowType, windowStartTime, windowEndTime | ||
var windowType = options.windowType || WindowTypes.STATIC; | ||
var liveSupport = options.liveSupport || MediaPlayerLiveSupport.SEEKABLE; | ||
var device = options.device; | ||
@@ -56,4 +81,3 @@ var subtitlesEnabled = options.subtitlesEnabled || false; | ||
bitrate: 'bitrate', | ||
manifest: options.manifest, | ||
manifestType: options.manifestType | ||
transferFormat: options.transferFormat | ||
}, | ||
@@ -64,6 +88,6 @@ serverDate: options.serverDate, | ||
if (windowType === WindowTypes.SLIDING && options.manifest === undefined) { | ||
if (options.windowStartTime && options.windowEndTime) { | ||
bigscreenPlayerData.time = { | ||
windowStartTime: options.windowStartTime !== undefined ? options.windowStartTime : 724000, | ||
windowEndTime: options.windowEndTime || 4324000 | ||
windowStartTime: options.windowStartTime, | ||
windowEndTime: options.windowEndTime | ||
}; | ||
@@ -76,3 +100,7 @@ } | ||
bigscreenPlayer.init(playbackElement, bigscreenPlayerData, windowType, subtitlesEnabled, liveSupport, device); | ||
var callbacks; | ||
if (!noCallbacks) { | ||
callbacks = {onSuccess: successCallback, onError: errorCallback}; | ||
} | ||
bigscreenPlayer.init(playbackElement, bigscreenPlayerData, windowType, subtitlesEnabled, device, callbacks); | ||
} | ||
@@ -82,6 +110,9 @@ | ||
beforeEach(function (done) { | ||
manifestParserMock = jasmine.createSpyObj('manifestParserSpy', ['parse']); | ||
setupManifestData(); | ||
liveSupport = LiveSupport.SEEKABLE; | ||
forceManifestLoadError = false; | ||
noCallbacks = false; | ||
injector.mock({ | ||
'bigscreenplayer/parsers/manifestparser': function () { return manifestParserMock; }, | ||
'bigscreenplayer/manifest/manifestloader': manifestLoaderMock, | ||
'bigscreenplayer/playercomponent': mockPlayerComponent, | ||
@@ -101,2 +132,4 @@ 'bigscreenplayer/plugins': Plugins | ||
}); | ||
successCallback.calls.reset(); | ||
errorCallback.calls.reset(); | ||
bigscreenPlayer.tearDown(); | ||
@@ -136,2 +169,39 @@ }); | ||
}); | ||
it('should call the suppiled success callback if playing VOD', function () { | ||
initialiseBigscreenPlayer(); | ||
expect(successCallback).toHaveBeenCalledWith(); | ||
expect(errorCallback).not.toHaveBeenCalled(); | ||
}); | ||
it('should call the suppiled success callback if playing LIVE and the manifest loads', function () { | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING}); | ||
expect(successCallback).toHaveBeenCalledWith(); | ||
expect(errorCallback).not.toHaveBeenCalled(); | ||
}); | ||
it('should call the supplied error callback if manifest fails to load', function () { | ||
forceManifestLoadError = true; | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING}); | ||
expect(errorCallback).toHaveBeenCalledWith({error: 'manifest'}); | ||
expect(successCallback).not.toHaveBeenCalled(); | ||
}); | ||
it('should not attempt to call onSuccess callback if one is not provided', function () { | ||
noCallbacks = true; | ||
initialiseBigscreenPlayer(); | ||
expect(successCallback).not.toHaveBeenCalled(); | ||
}); | ||
it('should not attempt to call onSuccess callback if one is not provided', function () { | ||
noCallbacks = true; | ||
forceManifestLoadError = true; | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING}); | ||
expect(errorCallback).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
@@ -311,5 +381,11 @@ | ||
it('should set endOfStream to true when seeking to the end of a simulcast', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 10, windowEndTime: 100, correction: 0}); | ||
setupManifestData({ | ||
transferFormat: TransferFormats.DASH, | ||
time: { | ||
windowStartTime: 10, | ||
windowEndTime: 100 | ||
} | ||
}); | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING, manifest: {}, manifestType: 'mpd'}); | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING}); | ||
@@ -332,2 +408,10 @@ var callback = jasmine.createSpy(); | ||
it('should set endOfStream to false when seeking into a simulcast', function () { | ||
setupManifestData({ | ||
transferFormat: TransferFormats.DASH, | ||
time: { | ||
windowStartTime: 10, | ||
windowEndTime: 100 | ||
} | ||
}); | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING}); | ||
@@ -403,7 +487,12 @@ | ||
it('should return liveWindowData when the windowType is sliding and manifest is provided', function () { | ||
var mockLiveData = {windowStartTime: 1, windowEndTime: 2}; | ||
manifestParserMock.parse.and.returnValue(mockLiveData); | ||
it('should return liveWindowData when the windowType is sliding and manifest is loaded', function () { | ||
setupManifestData({ | ||
transferFormat: TransferFormats.DASH, | ||
time: { | ||
windowStartTime: 1, | ||
windowEndTime: 2 | ||
} | ||
}); | ||
var initialisationData = {windowType: WindowTypes.SLIDING, manifest: true, serverDate: new Date(), initialPlaybackTime: new Date().getTime()}; | ||
var initialisationData = {windowType: WindowTypes.SLIDING, serverDate: new Date(), initialPlaybackTime: new Date().getTime()}; | ||
initialiseBigscreenPlayer(initialisationData); | ||
@@ -561,9 +650,6 @@ | ||
it('should return true when it can seek', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 0, windowEndTime: 150000000, correction: 0}); | ||
mockPlayerComponentInstance.getSeekableRange.and.returnValue({start: 0, end: 60}); | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING, | ||
liveSupport: MediaPlayerLiveSupport.SEEKABLE, | ||
manifest: {}, | ||
manifestType: 'mpd' | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -575,6 +661,7 @@ | ||
it('should return false when seekable range is infinite', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 0, windowEndTime: Infinity, correction: 0}); | ||
mockPlayerComponentInstance.getSeekableRange.and.returnValue({start: 0, end: Infinity}); | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING, liveSupport: MediaPlayerLiveSupport.SEEKABLE}); | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -585,10 +672,14 @@ expect(bigscreenPlayer.canSeek()).toBe(false); | ||
it('should return false when window length less than four minutes', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 0, windowEndTime: 239999, correction: 0}); | ||
setupManifestData({ | ||
transferFormat: 'dash', | ||
time: { | ||
windowStartTime: 0, | ||
windowEndTime: 239999, | ||
correction: 0 | ||
} | ||
}); | ||
mockPlayerComponentInstance.getSeekableRange.and.returnValue({start: 0, end: 60}); | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING, | ||
liveSupport: MediaPlayerLiveSupport.SEEKABLE, | ||
windowStartTime: 0, | ||
windowEndTime: 239999 | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -602,4 +693,8 @@ | ||
initialiseBigscreenPlayer({windowType: WindowTypes.SLIDING, liveSupport: MediaPlayerLiveSupport.RESTARTABLE}); | ||
liveSupport = LiveSupport.RESTARTABLE; | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
expect(bigscreenPlayer.canSeek()).toBe(false); | ||
@@ -619,8 +714,6 @@ }); | ||
it('should return true when it can pause', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 0, windowEndTime: 150000000, correction: 0}); | ||
liveSupport = LiveSupport.RESTARTABLE; | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING, | ||
liveSupport: MediaPlayerLiveSupport.RESTARTABLE, | ||
manifest: {}, | ||
manifestType: 'mpd' | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -632,9 +725,14 @@ | ||
it('should return false when window length less than four minutes', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 0, windowEndTime: 239999, correction: 0}); | ||
setupManifestData({ | ||
transferFormat: TransferFormats.DASH, | ||
time: { | ||
windowStartTime: 0, | ||
windowEndTime: 239999, | ||
correction: 0 | ||
} | ||
}); | ||
liveSupport = LiveSupport.RESTARTABLE; | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING, | ||
manifest: {}, | ||
manifestType: 'mpd', | ||
liveSupport: MediaPlayerLiveSupport.RESTARTABLE | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -646,6 +744,6 @@ | ||
it('should return false when device does not support pausing', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 0, windowEndTime: 150000000, correction: 0}); | ||
liveSupport = LiveSupport.PLAYABLE; | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING, | ||
liveSupport: MediaPlayerLiveSupport.PLAYABLE | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -660,10 +758,16 @@ | ||
it('converts video time to epoch time when windowStartTime is supplied', function () { | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 4200, windowEndTime: 150000000, correction: 0}); | ||
setupManifestData({ | ||
transferFormat: TransferFormats.DASH, | ||
time: { | ||
windowStartTime: 4200, | ||
windowEndTime: 150000000, | ||
correction: 0 | ||
} | ||
}); | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING, | ||
manifest: {}, | ||
manifestType: 'mpd' | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
expect(bigscreenPlayer.convertVideoTimeSecondsToEpochMs(1000)).toBe(bigscreenPlayerData.time.windowStartTime + 1000000); | ||
expect(bigscreenPlayer.convertVideoTimeSecondsToEpochMs(1000)).toBe(4200 + 1000000); | ||
}); | ||
@@ -682,7 +786,13 @@ | ||
// windowEndTime - 16 January 2019 14:00:00 | ||
manifestParserMock.parse.and.returnValue({windowStartTime: 1547640000000, windowEndTime: 1547647200000, correction: 0}); | ||
setupManifestData({ | ||
transferFormat: TransferFormats.DASH, | ||
time: { | ||
windowStartTime: 1547640000000, | ||
windowEndTime: 1547647200000, | ||
correction: 0 | ||
} | ||
}); | ||
initialiseBigscreenPlayer({ | ||
windowType: WindowTypes.SLIDING, | ||
manifest: {}, | ||
manifestType: 'mpd' | ||
windowType: WindowTypes.SLIDING | ||
}); | ||
@@ -763,2 +873,1 @@ | ||
); | ||
@@ -8,7 +8,8 @@ require( | ||
'bigscreenplayer/models/transportcontrolposition', | ||
'bigscreenplayer/models/livesupportenum', | ||
'bigscreenplayer/models/livesupport', | ||
'bigscreenplayer/pluginenums', | ||
'bigscreenplayer/models/transferformats', | ||
'squire' | ||
], | ||
function (MediaState, WindowTypes, MediaKinds, MockStrategy, TransportControlPosition, LiveSupport, PluginEnums, Squire) { | ||
function (MediaState, WindowTypes, MediaKinds, MockStrategy, TransportControlPosition, LiveSupport, PluginEnums, TransferFormats, Squire) { | ||
'use strict'; | ||
@@ -27,2 +28,3 @@ | ||
var corePlaybackData; | ||
var liveSupport; | ||
@@ -42,3 +44,3 @@ // opts = streamType, playbackType, mediaType, subtitlesAvailable, subtitlesEnabled noStatsReporter, disableUi | ||
type: opts.type || 'application/dash+xml', | ||
manifestType: opts.manifestType || 'mpd', | ||
transferFormat: opts.transferFormat || TransferFormats.DASH, | ||
bitrate: undefined, | ||
@@ -64,4 +66,3 @@ captionsUrl: opts.subtitlesAvailable ? 'captionsUrl' : undefined | ||
mockStateUpdateCallback, | ||
null, | ||
opts.liveSupport || 'none' | ||
null | ||
); | ||
@@ -89,2 +90,7 @@ } | ||
liveSupport = LiveSupport.SEEKABLE; | ||
mockStrategyConstructor.getLiveSupport = function () { | ||
return liveSupport; | ||
}; | ||
injector.mock({ | ||
@@ -974,3 +980,3 @@ 'bigscreenplayer/captionscontainer': mockCaptionsContainerConstructor, | ||
setUpPlayerComponent({multiCdn: true, manifestType: 'm3u8', windowType: WindowTypes.SLIDING}); | ||
setUpPlayerComponent({multiCdn: true, transferFormat: TransferFormats.HLS, windowType: WindowTypes.SLIDING}); | ||
@@ -991,3 +997,4 @@ mockStrategy.mockingHooks.fireErrorEvent({errorProperties: {}}); | ||
setUpPlayerComponent({multiCdn: true, manifestType: 'm3u8', windowType: WindowTypes.GROWING, liveSupport: LiveSupport.RESTARTABLE}); | ||
liveSupport = LiveSupport.RESTARTABLE; | ||
setUpPlayerComponent({multiCdn: true, transferFormat: TransferFormats.HLS, windowType: WindowTypes.GROWING}); | ||
@@ -1011,3 +1018,3 @@ mockStrategy.mockingHooks.fireErrorEvent({errorProperties: {}}); | ||
setUpPlayerComponent({multiCdn: true, manifestType: 'm3u8', windowType: WindowTypes.GROWING, liveSupport: LiveSupport.SEEKABLE, type: type}); | ||
setUpPlayerComponent({multiCdn: true, manifestType: 'm3u8', windowType: WindowTypes.GROWING, type: type}); | ||
@@ -1044,2 +1051,3 @@ // Set playback cause to normal | ||
liveSupport = LiveSupport.PLAYABLE; | ||
setUpPlayerComponent({multiCdn: true, manifestType: 'm3u8', windowType: WindowTypes.GROWING, liveSupport: LiveSupport.PLAYABLE, type: type}); | ||
@@ -1046,0 +1054,0 @@ |
@@ -12,6 +12,6 @@ define('bigscreenplayer/bigscreenplayer', | ||
'bigscreenplayer/debugger/debugtool', | ||
'bigscreenplayer/parsers/manifestparser', | ||
'bigscreenplayer/manifest/manifestloader', | ||
'bigscreenplayer/utils/timeutils' | ||
], | ||
function (MediaState, PlayerComponent, PauseTriggers, DynamicWindowUtils, WindowTypes, MockBigscreenPlayer, Plugins, Chronicle, DebugTool, ManifestParser, SlidingWindowUtils) { | ||
function (MediaState, PlayerComponent, PauseTriggers, DynamicWindowUtils, WindowTypes, MockBigscreenPlayer, Plugins, Chronicle, DebugTool, ManifestLoader, SlidingWindowUtils) { | ||
'use strict'; | ||
@@ -27,3 +27,2 @@ function BigscreenPlayer () { | ||
var serverDate; | ||
var liveSupport; | ||
var playerComponent; | ||
@@ -33,2 +32,3 @@ var pauseTrigger; | ||
var windowType; | ||
var device; | ||
@@ -88,54 +88,80 @@ function mediaStateUpdateCallback (evt) { | ||
return { | ||
init: function (playbackElement, bigscreenPlayerData, newWindowType, enableSubtitles, newLiveSupport, device) { | ||
Chronicle.init(); | ||
// TODO: make this more reusable so Player Component can do this for HLS Live CDN failover | ||
function needToGetManifest () { | ||
var requiresSimulcastSeekingData = { | ||
restartable: true, | ||
seekable: true, | ||
playable: false, | ||
none: false | ||
}; | ||
if (newWindowType !== WindowTypes.STATIC) { | ||
if (bigscreenPlayerData.time) { | ||
windowStartTime = bigscreenPlayerData.time.windowStartTime; | ||
windowEndTime = bigscreenPlayerData.time.windowEndTime; | ||
serverDate = bigscreenPlayerData.serverDate; | ||
} else if (bigscreenPlayerData.media.manifest) { | ||
var manifestParser = new ManifestParser(bigscreenPlayerData.media.manifest, bigscreenPlayerData.media.manifestType, bigscreenPlayerData.serverDate); | ||
var liveWindowData = manifestParser.parse(); | ||
return windowType !== WindowTypes.STATIC && requiresSimulcastSeekingData[getLiveSupport(device)]; | ||
} | ||
windowStartTime = liveWindowData.windowStartTime; | ||
windowEndTime = liveWindowData.windowEndTime; | ||
serverDate = bigscreenPlayerData.serverDate; | ||
function bigscreenPlayerDataLoaded (playbackElement, bigscreenPlayerData, enableSubtitles, device, successCallback) { | ||
if (bigscreenPlayerData.time) { | ||
windowStartTime = bigscreenPlayerData.time.windowStartTime; | ||
windowEndTime = bigscreenPlayerData.time.windowEndTime; | ||
serverDate = bigscreenPlayerData.serverDate; | ||
bigscreenPlayerData.time = {}; | ||
bigscreenPlayerData.time.windowStartTime = windowStartTime; | ||
bigscreenPlayerData.time.windowEndTime = windowEndTime; | ||
bigscreenPlayerData.time.correction = liveWindowData.timeCorrection; | ||
} | ||
initialPlaybackTimeEpoch = bigscreenPlayerData.initialPlaybackTime; | ||
// overwrite initialPlaybackTime with video time (it comes in as epoch time for a sliding/growing window) | ||
bigscreenPlayerData.initialPlaybackTime = SlidingWindowUtils.convertToSeekableVideoTime(bigscreenPlayerData.initialPlaybackTime, windowStartTime); | ||
} | ||
initialPlaybackTimeEpoch = bigscreenPlayerData.initialPlaybackTime; | ||
mediaKind = bigscreenPlayerData.media.kind; | ||
endOfStream = windowType !== WindowTypes.STATIC && (!bigscreenPlayerData.initialPlaybackTime && bigscreenPlayerData.initialPlaybackTime !== 0); | ||
// overwrite initialPlaybackTime with video time (it comes in as epoch time for a sliding/growing window) | ||
bigscreenPlayerData.initialPlaybackTime = SlidingWindowUtils.convertToSeekableVideoTime(bigscreenPlayerData.initialPlaybackTime, windowStartTime); | ||
} | ||
playerComponent = new PlayerComponent( | ||
playbackElement, | ||
bigscreenPlayerData, | ||
windowType, | ||
enableSubtitles, | ||
mediaStateUpdateCallback, | ||
device | ||
); | ||
mediaKind = bigscreenPlayerData.media.kind; | ||
if (successCallback) { | ||
successCallback(); | ||
} | ||
liveSupport = newLiveSupport; | ||
windowType = newWindowType; | ||
endOfStream = windowType !== WindowTypes.STATIC && (!bigscreenPlayerData.initialPlaybackTime && bigscreenPlayerData.initialPlaybackTime !== 0); | ||
var availableCdns = bigscreenPlayerData.media.urls.map(function (media) { | ||
return media.cdn; | ||
}); | ||
playerComponent = new PlayerComponent( | ||
playbackElement, | ||
bigscreenPlayerData, | ||
windowType, | ||
enableSubtitles, | ||
mediaStateUpdateCallback, | ||
device, | ||
liveSupport | ||
); | ||
DebugTool.keyValue({key: 'available cdns', value: availableCdns}); | ||
DebugTool.keyValue({key: 'current cdn', value: bigscreenPlayerData.media.urls[0].cdn}); | ||
DebugTool.keyValue({key: 'url', value: bigscreenPlayerData.media.urls[0].url}); | ||
} | ||
var availableCdns = bigscreenPlayerData.media.urls.map(function (media) { | ||
return media.cdn; | ||
}); | ||
return { | ||
init: function (playbackElement, bigscreenPlayerData, newWindowType, enableSubtitles, newDevice, callbacks) { | ||
Chronicle.init(); | ||
device = newDevice; | ||
windowType = newWindowType; | ||
serverDate = bigscreenPlayerData.serverDate; | ||
if (!callbacks) { | ||
callbacks = {}; | ||
} | ||
DebugTool.keyValue({key: 'available cdns', value: availableCdns}); | ||
DebugTool.keyValue({key: 'current cdn', value: bigscreenPlayerData.media.urls[0].cdn}); | ||
DebugTool.keyValue({key: 'url', value: bigscreenPlayerData.media.urls[0].url}); | ||
if (needToGetManifest() && !bigscreenPlayerData.time) { | ||
ManifestLoader.load( | ||
bigscreenPlayerData.media.urls, | ||
serverDate, | ||
{ | ||
onSuccess: function (manifestData) { | ||
bigscreenPlayerData.media.transferFormat = manifestData.transferFormat; | ||
bigscreenPlayerData.time = manifestData.time; | ||
bigscreenPlayerDataLoaded(playbackElement, bigscreenPlayerData, enableSubtitles, device, callbacks.onSuccess); | ||
}, | ||
onError: function () { | ||
if (callbacks.onError) { | ||
callbacks.onError({error: 'manifest'}); | ||
} | ||
} | ||
} | ||
); | ||
} else { | ||
bigscreenPlayerDataLoaded(playbackElement, bigscreenPlayerData, enableSubtitles, device, callbacks.onSuccess); | ||
} | ||
}, | ||
@@ -154,3 +180,2 @@ | ||
windowEndTime = undefined; | ||
liveSupport = undefined; | ||
pauseTrigger = undefined; | ||
@@ -248,6 +273,6 @@ windowType = undefined; | ||
canSeek: function () { | ||
return windowType === WindowTypes.STATIC || DynamicWindowUtils.canSeek(windowStartTime, windowEndTime, liveSupport, this.getSeekableRange()); | ||
return windowType === WindowTypes.STATIC || DynamicWindowUtils.canSeek(windowStartTime, windowEndTime, getLiveSupport(device), this.getSeekableRange()); | ||
}, | ||
canPause: function () { | ||
return windowType === WindowTypes.STATIC || DynamicWindowUtils.canPause(windowStartTime, windowEndTime, liveSupport); | ||
return windowType === WindowTypes.STATIC || DynamicWindowUtils.canPause(windowStartTime, windowEndTime, getLiveSupport(device)); | ||
}, | ||
@@ -282,4 +307,10 @@ mock: function (opts) { | ||
function getLiveSupport (device) { | ||
return PlayerComponent.getLiveSupport(device); | ||
} | ||
BigscreenPlayer.getLiveSupport = getLiveSupport; | ||
return BigscreenPlayer; | ||
} | ||
); |
define( | ||
'bigscreenplayer/dynamicwindowutils', [ | ||
'bigscreenplayer/models/livesupportenum' | ||
'bigscreenplayer/models/livesupport' | ||
], | ||
@@ -5,0 +5,0 @@ function (LiveSupport) { |
@@ -47,2 +47,3 @@ define('bigscreenplayer/mockbigscreenplayer', | ||
var liveWindowData; | ||
var manifestError; | ||
@@ -136,3 +137,3 @@ function startProgress (progressCause) { | ||
var mockFunctions = { | ||
init: function (playbackElement, bigscreenPlayerData, newWindowType, enableSubtitles, newLiveSupport) { | ||
init: function (playbackElement, bigscreenPlayerData, newWindowType, enableSubtitles, device, callbacks) { | ||
currentTime = (bigscreenPlayerData && bigscreenPlayerData.initialPlaybackTime) || 0; | ||
@@ -155,2 +156,9 @@ liveWindowStart = undefined; | ||
if (manifestError) { | ||
if (callbacks && callbacks.onError) { | ||
callbacks.onError({error: 'manifest'}); | ||
} | ||
return; | ||
} | ||
mockingHooks.changeState(MediaState.WAITING); | ||
@@ -163,2 +171,6 @@ | ||
initialised = true; | ||
if (callbacks && callbacks.onSuccess) { | ||
callbacks.onSuccess(); | ||
} | ||
}, | ||
@@ -258,2 +270,3 @@ registerForTimeUpdates: function (callback) { | ||
tearDown: function () { | ||
manifestError = false; | ||
if (!initialised) { | ||
@@ -383,2 +396,5 @@ return; | ||
}, | ||
triggerManifestError: function () { | ||
manifestError = true; | ||
}, | ||
triggerErrorHandled: function () { | ||
@@ -385,0 +401,0 @@ if (sourceList && sourceList.length > 1) { |
@@ -5,6 +5,7 @@ define('bigscreenplayer/playbackstrategy/hybridstrategy', | ||
'bigscreenplayer/playbackstrategy/msestrategy', | ||
'bigscreenplayer/playbackstrategy/strategypicker' | ||
'bigscreenplayer/playbackstrategy/strategypicker', | ||
'bigscreenplayer/models/livesupport' | ||
], | ||
function (Native, MSE, StrategyPicker) { | ||
return function (windowType, mediaKind, timeCorrection, videoElement, isUHD, device) { | ||
function (Native, MSE, StrategyPicker, LiveSupport) { | ||
var HybridStrategy = function (windowType, mediaKind, timeCorrection, videoElement, isUHD, device) { | ||
var strategy = StrategyPicker(windowType, isUHD); | ||
@@ -18,3 +19,9 @@ | ||
}; | ||
HybridStrategy.getLiveSupport = function () { | ||
return LiveSupport.SEEKABLE; | ||
}; | ||
return HybridStrategy; | ||
} | ||
); |
@@ -78,6 +78,12 @@ define('bigscreenplayer/playbackstrategy/mockstrategy', | ||
return function MockStrategy (playbackFrame, playbackType, streamType, mediaType, timeData, videoContainer) { | ||
var MockStrategy = function (playbackFrame, playbackType, streamType, mediaType, timeData, videoContainer) { | ||
return instance; | ||
}; | ||
MockStrategy.getLiveSupport = function () { | ||
return 'seekable'; | ||
}; | ||
return MockStrategy; | ||
} | ||
); |
@@ -8,3 +8,4 @@ define('bigscreenplayer/playbackstrategy/msestrategy', | ||
'bigscreenplayer/plugins', | ||
'bigscreenplayer/parsers/manifestfilter', | ||
'bigscreenplayer/manifest/manifestfilter', | ||
'bigscreenplayer/models/livesupport', | ||
@@ -14,4 +15,4 @@ // static imports | ||
], | ||
function (MediaState, WindowTypes, DebugTool, MediaKinds, Plugins, ManifestFilter) { | ||
return function (windowType, mediaKind, timeData, playbackElement) { | ||
function (MediaState, WindowTypes, DebugTool, MediaKinds, Plugins, ManifestFilter, LiveSupport) { | ||
var MSEStrategy = function (windowType, mediaKind, timeData, playbackElement) { | ||
var mediaPlayer; | ||
@@ -360,3 +361,9 @@ var eventCallback; | ||
}; | ||
MSEStrategy.getLiveSupport = function () { | ||
return LiveSupport.SEEKABLE; | ||
}; | ||
return MSEStrategy; | ||
} | ||
); |
@@ -9,3 +9,3 @@ define('bigscreenplayer/playbackstrategy/nativestrategy', | ||
function (LegacyAdapter, WindowTypes, Html5Player, LivePlayer) { | ||
return function (windowType, mediaKind, timeData, playbackElement, isUHD, device) { | ||
var NativeStrategy = function (windowType, mediaKind, timeData, playbackElement, isUHD, device) { | ||
var mediaPlayer; | ||
@@ -23,2 +23,8 @@ var logger = device.getLogger(); | ||
}; | ||
NativeStrategy.getLiveSupport = function () { | ||
return window.bigscreenPlayer.liveSupport; | ||
}; | ||
return NativeStrategy; | ||
}); |
@@ -7,3 +7,3 @@ define('bigscreenplayer/playbackstrategy/talstrategy', | ||
function (LegacyAdapter, WindowTypes) { | ||
return function (windowType, mediaKind, timeData, playbackElement, isUHD, device) { | ||
var TALStrategy = function (windowType, mediaKind, timeData, playbackElement, isUHD, device) { | ||
var mediaPlayer; | ||
@@ -19,2 +19,8 @@ | ||
}; | ||
TALStrategy.getLiveSupport = function (device) { | ||
return device.getLiveSupport(); | ||
}; | ||
return TALStrategy; | ||
}); |
@@ -8,12 +8,13 @@ define( | ||
'bigscreenplayer/utils/playbackutils', | ||
'bigscreenplayer/models/livesupportenum', | ||
'bigscreenplayer/models/livesupport', | ||
'bigscreenplayer/plugindata', | ||
'bigscreenplayer/pluginenums', | ||
'bigscreenplayer/plugins', | ||
'bigscreenplayer/debugger/debugtool' | ||
'bigscreenplayer/debugger/debugtool', | ||
'bigscreenplayer/models/transferformats' | ||
], | ||
function (MediaState, CaptionsContainer, PlaybackStrategy, WindowTypes, PlaybackUtils, LiveSupport, PluginData, PluginEnums, Plugins, DebugTool) { | ||
function (MediaState, CaptionsContainer, PlaybackStrategy, WindowTypes, PlaybackUtils, LiveSupport, PluginData, PluginEnums, Plugins, DebugTool, TransferFormats) { | ||
'use strict'; | ||
return function (playbackElement, bigscreenPlayerData, windowType, enableSubtitles, callback, device, newLiveSupport) { | ||
var PlayerComponent = function (playbackElement, bigscreenPlayerData, windowType, enableSubtitles, callback, device) { | ||
var isInitialPlay = true; | ||
@@ -31,4 +32,3 @@ var captionsURL = bigscreenPlayerData.media.captionsUrl; | ||
var fatalError; | ||
var transferFormat = bigscreenPlayerData.media.manifestType === 'mpd' ? 'dash' : 'hls'; | ||
var liveSupport = newLiveSupport; | ||
var transferFormat = bigscreenPlayerData.media.transferFormat; | ||
@@ -221,4 +221,6 @@ playbackStrategy = PlaybackStrategy( | ||
var canVodFailover = windowType === WindowTypes.STATIC && !aboutToEndVod; | ||
var canHlsLiveFailover = windowType === WindowTypes.GROWING && (liveSupport === LiveSupport.SEEKABLE || liveSupport === LiveSupport.PLAYABLE) && transferFormat === 'hls'; | ||
var canDashLiveFailover = windowType !== WindowTypes.STATIC && transferFormat === 'dash'; | ||
var canHlsLiveFailover = windowType === WindowTypes.GROWING && | ||
(getLiveSupport(device) === LiveSupport.SEEKABLE || getLiveSupport(device) === LiveSupport.PLAYABLE) && | ||
transferFormat === TransferFormats.HLS; | ||
var canDashLiveFailover = windowType !== WindowTypes.STATIC && transferFormat === TransferFormats.DASH; | ||
@@ -398,3 +400,11 @@ if (hasNextCDN && (canVodFailover || canHlsLiveFailover || canDashLiveFailover)) { | ||
}; | ||
function getLiveSupport (device) { | ||
return PlaybackStrategy.getLiveSupport(device); | ||
} | ||
PlayerComponent.getLiveSupport = getLiveSupport; | ||
return PlayerComponent; | ||
} | ||
); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
7532425
91
71520
16
221