define('application/components/players/catchup', [
'application/components/players/vod',
'application/decorators/player/interfaces/playerinterface',
'application/helpers/playerproperties',
'application/helpers/drmconfig',
'application/views/player/vod',
'rofl/lib/utils',
'application/utils',
'application/managers/api',
'application/constants',
'rofl/analytics/web/google',
'antie/runtimecontext'
], function (
VodComponent,
AppCorePlaybackInterface,
PlayerProperties,
DRMConfig,
VODView,
Utils,
AppUtils,
ApiManager,
Constants,
GoogleAnalytics,
RuntimeContext
) {
'use strict';
var api = ApiManager.getKPNAPI(),
application = RuntimeContext.getCurrentApplication(),
timeGap = 24 * 60 * 60 * 1000,
replayBuffer = 15 * 60 * 1000;
return VodComponent.extend({
/**
* Requests the content's stream data.
*
* @param {Object} playbackData - Playback content data.
* @returns {Object} - Stream data.
*/
_requestStream: function (playbackData) {
var program = playbackData.data;
return api.read('streams/catchup', {
params: playbackData,
withCredentials: true,
headers: this.getStreamHeaders(program)
});
},
/**
* Sets the given program.
*
* @param {Object} program - The program to set.
* @private
*/
_setProgram: function (program) {
var now = application.getDate().getTime(),
streamOffset = program.getStreamOffset(),
offsetTime = streamOffset * 4, // Offset time: 5 min at beginning, 15 minutes on the end.
startTime = streamOffset,
duration = program.getCatchupDuration() + offsetTime,
contentSubtype = program.getContentSubtype(),
contentId;
this._program = program;
this._endTime = new Date(program.getEndTime() * 1000).getTime();
if (now - this._endTime < replayBuffer) {
contentId = program.getChannelId();
} else {
contentId = program.getId();
}
startTime = (now - startTime < timeGap) ? (startTime - (5 * 60 * 1000)) : startTime;
this._program = program;
this._startTime = startTime || 0;
this._endTime = new Date(program.getEndTime() * 1000).getTime();
this._contentId = contentId;
this._type = AppUtils.getContentVideoType(program.getContentType(), contentSubtype);
this._view.setProgramInfoButton(program.getDetailsAction());
this._view.setNextEpisodeButton(false);
this._view.setProgram(program);
this._setProgress({
duration: duration,
currentTime: this._startTime,
percentage: (this._startTime / duration) * 100
});
this._buildSeeker();
},
/**
* No bookmark for this type.
*/
storeBookmark: function () {
}
});
});