define('application/views/player/live', [
'application/views/player/base',
'application/widgets/player/zappbanners/live',
'application/widgets/player/miniepg',
'application/constants',
'application/widgets/player/channelswitcher',
'antie/runtimecontext',
'rofl/analytics/web/google'
], function (
BaseView,
ZappBanner,
MiniEPG,
Constants,
ChannelSwitcher,
RuntimeContext,
GoogleAnalytics
) {
'use strict';
var CONTROLS = BaseView.CONTROLS,
application = RuntimeContext.getCurrentApplication(),
GA = GoogleAnalytics.getInstance(),
LiveView;
LiveView = BaseView.extend({
init: function init (viewParams) {
var user = application.getUser(),
controls = [
CONTROLS.INFO,
CONTROLS.RESTART,
CONTROLS.REWIND,
CONTROLS.PLAYPAUSE,
CONTROLS.FORWARD,
user && user.canRecord() ? CONTROLS.RECORD : null,
CONTROLS.MINIEPG,
CONTROLS.LIVE
];
this.CONTROLS = CONTROLS;
init.base.call(this, controls, viewParams);
this._buildMiniEpg();
this._buildChannelSwitcher();
},
/**
* Builds the zappbanner.
*
* @private
*/
_buildZappBanner: function _buildZappBanner () {
_buildZappBanner.base.call(this, new ZappBanner());
},
/**
* Builds the channel switcher.
*
* @private
*/
_buildChannelSwitcher: function () {
var channelSwitcher = this._channelSwitcher = new ChannelSwitcher();
this.appendChildWidget(channelSwitcher);
},
/**
* Sets the channel number into the switcher label.
*
* @param {string} [channelNumber] - The channel number to show.
*/
setChannelSwitcherLabel: function (channelNumber) {
var channelNumberText = isNaN(Number(channelNumber)) ? '' : channelNumber;
this._channelSwitcher.setLabel(channelNumberText);
},
/**
* Updates the progress on zappbanner.
*
* @param {Object} progressData - Progress data.
*/
setProgress: function setProgress (progressData) {
setProgress.base.call(this, progressData);
if (progressData.behind < 0) {
this._controls.disableLiveButton(false);
} else {
this.resetLiveLabels();
}
},
/**
* Sets the record state.
*/
onRecord: function () {
this._controls.onRecord();
},
/**
* Sets the recording state.
*/
onRecording: function () {
this._controls.onRecording();
},
/**
* Builds the miniEPG widget.
*
* @private
*/
_buildMiniEpg: function () {
this._miniEPG = this._bottomBar.appendChildWidget(new MiniEPG());
},
/**
* Shows or hides the mini epg.
*
* @param {boolean} hide - True if the miniEPG should be hidden.
*/
showMiniEPG: function (hide) {
this._controls.onMiniEPG(hide);
if (this._miniEPG.isExpanded() || hide) {
this._miniEPG.removeClass('expand');
} else {
this.showProgramInfo(false);
this._sendMiniEpgOpenedAnalytics();
this._miniEPG.addClass('expand');
}
},
/**
* Resets live button and labels to default live state.
*/
resetLiveLabels: function () {
this._zappBanner.resetPauseLabel();
this._controls.disableLiveButton(true);
},
/**
* Send analytics for opening mini epg.
*
* @private
*/
_sendMiniEpgOpenedAnalytics: function () {
GA.onEvent(
Constants.ANALYTICS_EVENT_CATEGORY_ACTION,
Constants.ANALYTICS_EVENT_ACTION_MINIEPG_OPENED,
{
eventLabel: Constants.ANALYTICS_EVENT_LABEL_TYPE_LIVETV
}
);
}
});
LiveView.CONTROLS = CONTROLS;
return LiveView;
});