2014-03-08 01:09:45 -07:00
|
|
|
|
(function () {
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
function createVideoPlayer(self) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 01:34:54 -07:00
|
|
|
|
var initialVolume;
|
2014-03-18 12:57:32 -07:00
|
|
|
|
var idleState = true;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
var muteButton = null;
|
|
|
|
|
var unmuteButton = null;
|
|
|
|
|
var volumeSlider = null;
|
|
|
|
|
var positionSlider;
|
|
|
|
|
var currentTimeElement;
|
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
self.currentSubtitleStreamIndex = null;
|
|
|
|
|
|
2014-06-11 19:38:40 -07:00
|
|
|
|
self.getCurrentSubtitleStream = function () {
|
|
|
|
|
return self.getSubtitleStream(self.currentSubtitleStreamIndex);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.getSubtitleStream = function (index) {
|
|
|
|
|
return self.currentMediaSource.MediaStreams.filter(function (s) {
|
|
|
|
|
return s.Type == 'Subtitle' && s.Index == index;
|
|
|
|
|
})[0];
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
self.toggleFullscreen = function () {
|
|
|
|
|
if (self.isFullScreen()) {
|
2015-05-17 18:27:48 -07:00
|
|
|
|
|
|
|
|
|
self.exitFullScreen();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else {
|
2014-03-24 20:26:54 -07:00
|
|
|
|
requestFullScreen(document.body);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.resetEnhancements = function () {
|
2015-08-28 12:10:44 -07:00
|
|
|
|
|
|
|
|
|
fadeOut(document.querySelector('#mediaPlayer'));
|
2014-10-09 15:22:04 -07:00
|
|
|
|
$('#videoPlayer').removeClass('fullscreenVideo').removeClass('idlePlayer');
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.hiddenOnIdle').removeClass("inactive");
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$("video").remove();
|
2015-08-28 12:10:44 -07:00
|
|
|
|
|
|
|
|
|
document.querySelector('.mediaButton.infoButton').classList.remove('active');
|
|
|
|
|
document.querySelector('.videoControls .nowPlayingInfo').classList.add('hide');
|
|
|
|
|
document.querySelector('.videoControls').classList.add('hiddenOnIdle');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-08-28 12:10:44 -07:00
|
|
|
|
function fadeOut(elem) {
|
|
|
|
|
$(elem).hide();
|
|
|
|
|
return;
|
|
|
|
|
var keyframes = [
|
|
|
|
|
{ opacity: '1', offset: 0 },
|
|
|
|
|
{ opacity: '0', offset: 1 }];
|
|
|
|
|
var timing = { duration: 300, iterations: 1 };
|
|
|
|
|
elem.animate(keyframes, timing).onfinish = function () {
|
|
|
|
|
$(elem).hide();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
self.exitFullScreen = function () {
|
2015-05-17 18:27:48 -07:00
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
if (document.exitFullscreen) {
|
|
|
|
|
document.exitFullscreen();
|
2015-05-27 22:51:48 -07:00
|
|
|
|
} else if (document.mozCancelFullScreen) {
|
|
|
|
|
document.mozCancelFullScreen();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else if (document.webkitExitFullscreen) {
|
|
|
|
|
document.webkitExitFullscreen();
|
2015-05-17 18:27:48 -07:00
|
|
|
|
} else if (document.msExitFullscreen) {
|
|
|
|
|
document.msExitFullscreen();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
$('#videoPlayer').removeClass('fullscreenVideo');
|
2014-03-17 07:48:16 -07:00
|
|
|
|
};
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
self.isFullScreen = function () {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
return document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement ? true : false;
|
2014-03-17 07:48:16 -07:00
|
|
|
|
};
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
self.showSubtitleMenu = function () {
|
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var streams = self.currentMediaSource.MediaStreams.filter(function (currentStream) {
|
|
|
|
|
return currentStream.Type == "Subtitle";
|
|
|
|
|
});
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var currentIndex = self.currentSubtitleStreamIndex || -1;
|
|
|
|
|
|
|
|
|
|
streams.unshift({
|
|
|
|
|
Index: -1,
|
|
|
|
|
Language: "Off"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var menuItems = streams.map(function (stream) {
|
|
|
|
|
|
|
|
|
|
var attributes = [];
|
|
|
|
|
|
|
|
|
|
attributes.push(stream.Language || Globalize.translate('LabelUnknownLanguage'));
|
|
|
|
|
|
|
|
|
|
if (stream.Codec) {
|
|
|
|
|
attributes.push(stream.Codec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var name = attributes.join(' - ');
|
|
|
|
|
|
|
|
|
|
if (stream.IsDefault) {
|
|
|
|
|
name += ' (D)';
|
|
|
|
|
}
|
|
|
|
|
if (stream.IsForced) {
|
|
|
|
|
name += ' (F)';
|
|
|
|
|
}
|
|
|
|
|
if (stream.External) {
|
|
|
|
|
name += ' (EXT)';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opt = {
|
|
|
|
|
name: name,
|
|
|
|
|
id: stream.Index
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (stream.Index == currentIndex) {
|
|
|
|
|
opt.ironIcon = "check";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return opt;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
require(['actionsheet'], function () {
|
|
|
|
|
|
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: $('.videoSubtitleButton')[0],
|
|
|
|
|
callback: function (id) {
|
|
|
|
|
|
|
|
|
|
var index = parseInt(id);
|
|
|
|
|
if (index != currentIndex) {
|
|
|
|
|
self.onSubtitleOptionSelected(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
});
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
self.showQualityFlyout = function () {
|
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var currentSrc = self.getCurrentSrc(self.currentMediaRenderer).toLowerCase();
|
|
|
|
|
var isStatic = currentSrc.indexOf('static=true') != -1;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var videoStream = self.currentMediaSource.MediaStreams.filter(function (stream) {
|
|
|
|
|
return stream.Type == "Video";
|
|
|
|
|
})[0];
|
|
|
|
|
var videoWidth = videoStream ? videoStream.Width : null;
|
|
|
|
|
var videoHeight = videoStream ? videoStream.Height : null;
|
|
|
|
|
|
|
|
|
|
var options = self.getVideoQualityOptions(videoWidth, videoHeight);
|
|
|
|
|
|
|
|
|
|
if (isStatic) {
|
|
|
|
|
options[0].name = "Direct";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var menuItems = options.map(function (o) {
|
|
|
|
|
|
|
|
|
|
var opt = {
|
|
|
|
|
name: o.name,
|
|
|
|
|
id: o.bitrate
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (o.selected) {
|
|
|
|
|
opt.ironIcon = "check";
|
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
return opt;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var selectedId = options.filter(function (o) {
|
|
|
|
|
return o.selected;
|
|
|
|
|
});
|
|
|
|
|
selectedId = selectedId.length ? selectedId[0].bitrate : null;
|
|
|
|
|
require(['actionsheet'], function () {
|
|
|
|
|
|
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: $('.videoQualityButton')[0],
|
|
|
|
|
callback: function (id) {
|
|
|
|
|
|
|
|
|
|
var bitrate = parseInt(id);
|
|
|
|
|
if (bitrate != selectedId) {
|
|
|
|
|
self.onQualityOptionSelected(bitrate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.showAudioTracksFlyout = function () {
|
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var options = self.currentMediaSource.MediaStreams.filter(function (currentStream) {
|
|
|
|
|
return currentStream.Type == "Audio";
|
|
|
|
|
});
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var currentIndex = getParameterByName('AudioStreamIndex', self.getCurrentSrc(self.currentMediaRenderer));
|
|
|
|
|
|
|
|
|
|
var menuItems = options.map(function (stream) {
|
|
|
|
|
|
|
|
|
|
var attributes = [];
|
|
|
|
|
|
|
|
|
|
attributes.push(stream.Language || Globalize.translate('LabelUnknownLanguage'));
|
|
|
|
|
|
|
|
|
|
if (stream.Codec) {
|
|
|
|
|
attributes.push(stream.Codec);
|
|
|
|
|
}
|
|
|
|
|
if (stream.Profile) {
|
|
|
|
|
attributes.push(stream.Profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stream.BitRate) {
|
|
|
|
|
attributes.push((Math.floor(stream.BitRate / 1000)) + ' kbps');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stream.Channels) {
|
|
|
|
|
attributes.push(stream.Channels + ' ch');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var name = attributes.join(' - ');
|
|
|
|
|
|
|
|
|
|
if (stream.IsDefault) {
|
|
|
|
|
name += ' (D)';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var opt = {
|
|
|
|
|
name: name,
|
|
|
|
|
id: stream.Index
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (stream.Index == currentIndex) {
|
|
|
|
|
opt.ironIcon = "check";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return opt;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
require(['actionsheet'], function () {
|
|
|
|
|
|
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: $('.videoAudioButton')[0],
|
|
|
|
|
callback: function (id) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
var index = parseInt(id);
|
|
|
|
|
if (index != currentIndex) {
|
|
|
|
|
self.onAudioOptionSelected(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
self.setAudioStreamIndex = function (index) {
|
|
|
|
|
self.changeStream(self.getCurrentTicks(), { AudioStreamIndex: index });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.setSubtitleStreamIndex = function (index) {
|
2014-06-11 19:38:40 -07:00
|
|
|
|
|
2015-06-13 07:46:59 -07:00
|
|
|
|
if (!self.currentMediaRenderer.supportsTextTracks()) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2014-06-11 19:38:40 -07:00
|
|
|
|
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
|
|
|
|
self.currentSubtitleStreamIndex = index;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentStream = self.getCurrentSubtitleStream();
|
|
|
|
|
|
|
|
|
|
var newStream = self.getSubtitleStream(index);
|
|
|
|
|
|
|
|
|
|
if (!currentStream && !newStream) return;
|
|
|
|
|
|
|
|
|
|
var selectedTrackElementIndex = -1;
|
|
|
|
|
|
|
|
|
|
if (currentStream && !newStream) {
|
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
if (currentStream.DeliveryMethod != 'External') {
|
2014-06-11 19:38:40 -07:00
|
|
|
|
|
|
|
|
|
// Need to change the transcoded stream to remove subs
|
|
|
|
|
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: -1 });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!currentStream && newStream) {
|
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
if (newStream.DeliveryMethod == 'External') {
|
2014-06-11 19:38:40 -07:00
|
|
|
|
selectedTrackElementIndex = index;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Need to change the transcoded stream to add subs
|
|
|
|
|
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-14 19:24:04 -07:00
|
|
|
|
else if (currentStream && newStream) {
|
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
if (newStream.DeliveryMethod == 'External') {
|
2014-06-14 19:24:04 -07:00
|
|
|
|
selectedTrackElementIndex = index;
|
2014-06-14 19:58:00 -07:00
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
if (currentStream.DeliveryMethod != 'External') {
|
2014-06-14 19:24:04 -07:00
|
|
|
|
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: -1 });
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Need to change the transcoded stream to add subs
|
|
|
|
|
self.changeStream(self.getCurrentTicks(), { SubtitleStreamIndex: index });
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-11 19:38:40 -07:00
|
|
|
|
|
|
|
|
|
self.setCurrentTrackElement(selectedTrackElementIndex);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2014-06-11 19:38:40 -07:00
|
|
|
|
self.currentSubtitleStreamIndex = index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.setCurrentTrackElement = function (index) {
|
|
|
|
|
|
|
|
|
|
var textStreams = self.currentMediaSource.MediaStreams.filter(function (s) {
|
2015-03-30 12:57:37 -07:00
|
|
|
|
return s.DeliveryMethod == 'External';
|
2014-06-11 19:38:40 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var newStream = textStreams.filter(function (s) {
|
|
|
|
|
return s.Index == index;
|
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
|
|
var trackIndex = newStream ? textStreams.indexOf(newStream) : -1;
|
|
|
|
|
|
2015-06-13 07:46:59 -07:00
|
|
|
|
self.currentMediaRenderer.setCurrentTrackElement(trackIndex);
|
2014-05-07 22:04:39 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-06-14 19:58:00 -07:00
|
|
|
|
self.updateTextStreamUrls = function (startPositionTicks) {
|
|
|
|
|
|
2015-06-13 07:46:59 -07:00
|
|
|
|
self.currentMediaRenderer.updateTextStreamUrls(startPositionTicks);
|
2014-06-14 19:58:00 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
self.updateNowPlayingInfo = function (item) {
|
|
|
|
|
|
|
|
|
|
if (!item) {
|
|
|
|
|
throw new Error('item cannot be null');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mediaControls = $("#videoPlayer");
|
|
|
|
|
|
2015-08-30 21:57:12 -07:00
|
|
|
|
var state = self.getPlayerStateInternal(self.currentMediaRenderer, item.CurrentProgram || item, self.currentMediaSource);
|
2014-06-28 12:35:30 -07:00
|
|
|
|
|
|
|
|
|
var url = "";
|
2015-05-13 13:55:08 -07:00
|
|
|
|
var imageWidth = 400;
|
2015-05-13 22:42:55 -07:00
|
|
|
|
var imageHeight = 300;
|
2014-06-28 12:35:30 -07:00
|
|
|
|
|
|
|
|
|
if (state.NowPlayingItem.PrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(state.NowPlayingItem.PrimaryImageItemId, {
|
|
|
|
|
type: "Primary",
|
2015-05-13 10:53:26 -07:00
|
|
|
|
width: imageWidth,
|
2014-06-28 12:35:30 -07:00
|
|
|
|
tag: state.NowPlayingItem.PrimaryImageTag
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (state.NowPlayingItem.PrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(state.NowPlayingItem.PrimaryImageItemId, {
|
|
|
|
|
type: "Primary",
|
2015-05-13 10:53:26 -07:00
|
|
|
|
width: imageWidth,
|
2014-06-28 12:35:30 -07:00
|
|
|
|
tag: state.NowPlayingItem.PrimaryImageTag
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (state.NowPlayingItem.BackdropImageTag) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(state.NowPlayingItem.BackdropItemId, {
|
|
|
|
|
type: "Backdrop",
|
2015-05-13 10:53:26 -07:00
|
|
|
|
height: imageHeight,
|
2014-06-28 12:35:30 -07:00
|
|
|
|
tag: state.NowPlayingItem.BackdropImageTag,
|
|
|
|
|
index: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (state.NowPlayingItem.ThumbImageTag) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(state.NowPlayingItem.ThumbImageItemId, {
|
|
|
|
|
type: "Thumb",
|
2015-05-13 10:53:26 -07:00
|
|
|
|
height: imageHeight,
|
2014-06-28 12:35:30 -07:00
|
|
|
|
tag: state.NowPlayingItem.ThumbImageTag
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
|
$('.nowPlayingImage', mediaControls).html('<img src="' + url + '" />');
|
|
|
|
|
} else {
|
|
|
|
|
$('.nowPlayingImage', mediaControls).html('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state.NowPlayingItem.LogoItemId) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(state.NowPlayingItem.LogoItemId, {
|
|
|
|
|
type: "Logo",
|
2014-06-28 19:30:20 -07:00
|
|
|
|
height: 42,
|
2014-06-28 12:35:30 -07:00
|
|
|
|
tag: state.NowPlayingItem.LogoImageTag
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.videoTopControlsLogo', mediaControls).html('<img src="' + url + '" />');
|
|
|
|
|
} else {
|
|
|
|
|
$('.videoTopControlsLogo', mediaControls).html('');
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-30 21:57:12 -07:00
|
|
|
|
var elem = $('.nowPlayingTabs', mediaControls).html(getNowPlayingTabsHtml(item.CurrentProgram || item)).lazyChildren();
|
2015-05-13 20:24:25 -07:00
|
|
|
|
|
|
|
|
|
$('.nowPlayingTabButton', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
if (!$(this).hasClass('selectedNowPlayingTabButton')) {
|
|
|
|
|
$('.selectedNowPlayingTabButton').removeClass('selectedNowPlayingTabButton');
|
|
|
|
|
$(this).addClass('selectedNowPlayingTabButton');
|
|
|
|
|
$('.nowPlayingTab').hide();
|
2015-05-13 22:42:55 -07:00
|
|
|
|
$('.' + this.getAttribute('data-tab')).show().trigger('scroll');
|
2015-05-13 20:24:25 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.chapterCard', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
self.seek(parseInt(this.getAttribute('data-position')));
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getNowPlayingTabsHtml(item) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="nowPlayingTabButtons">';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" class="nowPlayingTabButton selectedNowPlayingTabButton" data-tab="tabInfo">' + Globalize.translate('TabInfo') + '</a>';
|
|
|
|
|
|
|
|
|
|
if (item.Chapters && item.Chapters.length) {
|
|
|
|
|
html += '<a href="#" class="nowPlayingTabButton" data-tab="tabScenes">' + Globalize.translate('TabScenes') + '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.People && item.People.length) {
|
|
|
|
|
html += '<a href="#" class="nowPlayingTabButton" data-tab="tabCast">' + Globalize.translate('TabCast') + '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="tabInfo nowPlayingTab">';
|
|
|
|
|
var nameHtml = MediaController.getNowPlayingNameHtml(item, false);
|
2015-05-13 10:53:26 -07:00
|
|
|
|
nameHtml = '<div class="videoNowPlayingName">' + nameHtml + '</div>';
|
|
|
|
|
|
|
|
|
|
var miscInfo = LibraryBrowser.getMiscInfoHtml(item);
|
|
|
|
|
if (miscInfo) {
|
|
|
|
|
|
|
|
|
|
nameHtml += '<div class="videoNowPlayingRating">' + miscInfo + '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ratingHtml = LibraryBrowser.getRatingHtml(item);
|
|
|
|
|
if (ratingHtml) {
|
|
|
|
|
|
|
|
|
|
nameHtml += '<div class="videoNowPlayingRating">' + ratingHtml + '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Overview) {
|
|
|
|
|
|
|
|
|
|
nameHtml += '<div class="videoNowPlayingOverview">' + item.Overview + '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-13 20:24:25 -07:00
|
|
|
|
html += nameHtml;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (item.Chapters && item.Chapters.length) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
html += '<div class="tabScenes nowPlayingTab hiddenScrollX" style="display:none;white-space:nowrap;margin-bottom:2em;">';
|
2015-05-13 20:24:25 -07:00
|
|
|
|
var chapterIndex = 0;
|
|
|
|
|
html += item.Chapters.map(function (c) {
|
|
|
|
|
|
2015-06-11 10:57:59 -07:00
|
|
|
|
var width = 240;
|
2015-05-13 20:24:25 -07:00
|
|
|
|
var chapterHtml = '<a class="card backdropCard chapterCard" href="#" style="margin-right:1em;width:' + width + 'px;" data-position="' + c.StartPositionTicks + '">';
|
|
|
|
|
chapterHtml += '<div class="cardBox">';
|
|
|
|
|
chapterHtml += '<div class="cardScalable">';
|
|
|
|
|
chapterHtml += '<div class="cardPadder"></div>';
|
|
|
|
|
|
|
|
|
|
chapterHtml += '<div class="cardContent">';
|
|
|
|
|
|
|
|
|
|
if (c.ImageTag) {
|
|
|
|
|
|
|
|
|
|
var chapterImageUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
width: width,
|
|
|
|
|
tag: c.ImageTag,
|
|
|
|
|
type: "Chapter",
|
|
|
|
|
index: chapterIndex
|
|
|
|
|
});
|
|
|
|
|
chapterHtml += '<div class="cardImage lazy" data-src="' + chapterImageUrl + '"></div>';
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
chapterHtml += '<div class="cardImage" style="background:#444;"></div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chapterHtml += '<div class="cardFooter">';
|
|
|
|
|
if (c.Name) {
|
|
|
|
|
chapterHtml += '<div class="cardText">' + c.Name + '</div>';
|
|
|
|
|
}
|
|
|
|
|
chapterHtml += '<div class="cardText">' + Dashboard.getDisplayTime(c.StartPositionTicks) + '</div>';
|
|
|
|
|
chapterHtml += '</div>';
|
|
|
|
|
chapterHtml += '</div>';
|
|
|
|
|
|
|
|
|
|
chapterHtml += '</div>';
|
|
|
|
|
chapterHtml += '</div>';
|
|
|
|
|
chapterHtml += '</a>';
|
|
|
|
|
|
|
|
|
|
chapterIndex++;
|
|
|
|
|
|
|
|
|
|
return chapterHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.People && item.People.length) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
html += '<div class="tabCast nowPlayingTab hiddenScrollX" style="display:none;white-space:nowrap;">';
|
2015-05-13 20:24:25 -07:00
|
|
|
|
html += item.People.map(function (cast) {
|
|
|
|
|
|
|
|
|
|
var personHtml = '<div class="tileItem smallPosterTileItem" style="width:300px;">';
|
|
|
|
|
|
|
|
|
|
var imgUrl;
|
2015-07-03 04:51:45 -07:00
|
|
|
|
var height = 150;
|
2015-05-13 20:24:25 -07:00
|
|
|
|
|
|
|
|
|
if (cast.PrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(cast.Id, {
|
2015-05-27 22:51:48 -07:00
|
|
|
|
height: height,
|
2015-05-13 20:24:25 -07:00
|
|
|
|
tag: cast.PrimaryImageTag,
|
|
|
|
|
type: "primary",
|
|
|
|
|
minScale: 2
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-11 19:18:09 -07:00
|
|
|
|
personHtml += '<div class="tileImage lazy" data-src="' + imgUrl + '" style="height:' + height + 'px;"></div>';
|
2015-05-13 20:24:25 -07:00
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
imgUrl = "css/images/items/list/person.png";
|
2015-09-11 19:18:09 -07:00
|
|
|
|
personHtml += '<div class="tileImage" style="background-image:url(\'' + imgUrl + '\');height:' + height + 'px;"></div>';
|
2015-05-13 20:24:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
personHtml += '<div class="tileContent">';
|
|
|
|
|
|
|
|
|
|
personHtml += '<p>' + cast.Name + '</p>';
|
|
|
|
|
|
|
|
|
|
var role = cast.Role ? Globalize.translate('ValueAsRole', cast.Role) : cast.Type;
|
|
|
|
|
|
|
|
|
|
if (role == "GuestStar") {
|
|
|
|
|
role = Globalize.translate('ValueGuestStar');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
role = role || "";
|
|
|
|
|
|
|
|
|
|
var maxlength = 40;
|
|
|
|
|
|
|
|
|
|
if (role.length > maxlength) {
|
|
|
|
|
role = role.substring(0, maxlength - 3) + '...';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
personHtml += '<p>' + role + '</p>';
|
|
|
|
|
|
|
|
|
|
personHtml += '</div>';
|
|
|
|
|
|
|
|
|
|
personHtml += '</div>';
|
|
|
|
|
return personHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
2014-06-28 12:35:30 -07:00
|
|
|
|
|
2015-09-09 10:49:44 -07:00
|
|
|
|
function getSeekableDuration() {
|
|
|
|
|
|
|
|
|
|
if (self.currentMediaSource && self.currentMediaSource.RunTimeTicks) {
|
|
|
|
|
return self.currentMediaSource.RunTimeTicks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.currentMediaRenderer) {
|
|
|
|
|
return self.getCurrentTicks(self.currentMediaRenderer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
function onPositionSliderChange() {
|
|
|
|
|
|
|
|
|
|
var newPercent = parseInt(this.value);
|
|
|
|
|
|
2015-09-09 10:49:44 -07:00
|
|
|
|
var newPositionTicks = (newPercent / 100) * getSeekableDuration();
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
|
|
|
|
self.changeStream(Math.floor(newPositionTicks));
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
self.onAudioOptionSelected = function (index) {
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
self.setAudioStreamIndex(index);
|
|
|
|
|
};
|
2015-05-22 13:15:29 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
self.onSubtitleOptionSelected = function (index) {
|
|
|
|
|
|
|
|
|
|
self.setSubtitleStreamIndex(index);
|
2015-05-22 13:15:29 -07:00
|
|
|
|
};
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
self.onQualityOptionSelected = function (bitrate) {
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
AppSettings.maxStreamingBitrate(bitrate);
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
self.changeStream(self.getCurrentTicks(), {
|
|
|
|
|
Bitrate: bitrate
|
|
|
|
|
});
|
2015-05-22 13:15:29 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-08-28 12:10:44 -07:00
|
|
|
|
self.toggleInfo = function () {
|
|
|
|
|
|
|
|
|
|
var button = document.querySelector('.mediaButton.infoButton');
|
|
|
|
|
var nowPlayingInfo = document.querySelector('.videoControls .nowPlayingInfo');
|
|
|
|
|
|
|
|
|
|
if (button.classList.contains('active')) {
|
|
|
|
|
button.classList.remove('active');
|
|
|
|
|
document.querySelector('.videoControls').classList.add('hiddenOnIdle');
|
|
|
|
|
|
|
|
|
|
fadeOutDown(nowPlayingInfo);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
button.classList.add('active');
|
|
|
|
|
document.querySelector('.videoControls').classList.remove('hiddenOnIdle');
|
|
|
|
|
nowPlayingInfo.classList.remove('hide');
|
|
|
|
|
fadeInUp(nowPlayingInfo);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function fadeInUp(elem) {
|
|
|
|
|
var keyframes = [
|
|
|
|
|
{ transform: 'translate3d(0, 100%, 0)', offset: 0 },
|
|
|
|
|
{ transform: 'none', offset: 1 }];
|
|
|
|
|
var timing = { duration: 300, iterations: 1 };
|
|
|
|
|
elem.animate(keyframes, timing);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fadeOutDown(elem) {
|
|
|
|
|
var keyframes = [{ transform: 'none', offset: 0 },
|
|
|
|
|
{ transform: 'translate3d(0, 100%, 0)', offset: 1 }];
|
|
|
|
|
var timing = { duration: 300, iterations: 1 };
|
|
|
|
|
elem.animate(keyframes, timing).onfinish = function () {
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
function ensureVideoPlayerElements() {
|
2015-05-22 13:15:29 -07:00
|
|
|
|
|
2015-07-03 04:51:45 -07:00
|
|
|
|
var html = '<div id="mediaPlayer" style="display: none;">';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<div class="videoBackdrop">';
|
|
|
|
|
html += '<div id="videoPlayer">';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<div id="videoElement">';
|
|
|
|
|
html += '<div id="play" class="status"></div>';
|
|
|
|
|
html += '<div id="pause" class="status"></div>';
|
|
|
|
|
html += '</div>';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<div class="videoTopControls hiddenOnIdle">';
|
|
|
|
|
html += '<div class="videoTopControlsLogo"></div>';
|
|
|
|
|
html += '<div class="videoAdvancedControls">';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="skip-previous" class="previousTrackButton mediaButton videoTrackControl hide" onclick="MediaPlayer.previousTrack();"></paper-icon-button>';
|
|
|
|
|
html += '<paper-icon-button icon="skip-next" class="nextTrackButton mediaButton videoTrackControl hide" onclick="MediaPlayer.nextTrack();"></paper-icon-button>';
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
// Embedding onclicks due to issues not firing in cordova safari
|
|
|
|
|
html += '<paper-icon-button icon="audiotrack" class="mediaButton videoAudioButton" onclick="MediaPlayer.showAudioTracksFlyout();"></paper-icon-button>';
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
2015-09-08 07:35:52 -07:00
|
|
|
|
html += '<paper-icon-button icon="closed-caption" class="mediaButton videoSubtitleButton" onclick="MediaPlayer.showSubtitleMenu();"></paper-icon-button>';
|
2015-06-25 14:50:56 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<paper-icon-button icon="settings" class="mediaButton videoQualityButton" onclick="MediaPlayer.showQualityFlyout();"></paper-icon-button>';
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<paper-icon-button icon="close" class="mediaButton" onclick="MediaPlayer.stop();"></paper-icon-button>';
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '</div>'; // videoAdvancedControls
|
|
|
|
|
html += '</div>'; // videoTopControls
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
// Create controls
|
|
|
|
|
html += '<div class="videoControls hiddenOnIdle">';
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
2015-08-28 12:10:44 -07:00
|
|
|
|
html += '<div class="nowPlayingInfo hide">';
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<div class="nowPlayingImage"></div>';
|
|
|
|
|
html += '<div class="nowPlayingTabs"></div>';
|
|
|
|
|
html += '</div>'; // nowPlayingInfo
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
2015-08-28 12:10:44 -07:00
|
|
|
|
html += '<div class="videoControlButtons">';
|
2015-07-08 09:10:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="skip-previous" class="previousTrackButton mediaButton videoTrackControl hide" onclick="MediaPlayer.previousTrack();"></paper-icon-button>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<paper-icon-button id="video-playButton" icon="play-arrow" class="mediaButton unpauseButton" onclick="MediaPlayer.unpause();"></paper-icon-button>';
|
|
|
|
|
html += '<paper-icon-button id="video-pauseButton" icon="pause" class="mediaButton pauseButton" onclick="MediaPlayer.pause();"></paper-icon-button>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="skip-next" class="nextTrackButton mediaButton videoTrackControl hide" onclick="MediaPlayer.nextTrack();"></paper-icon-button>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-09-08 07:35:52 -07:00
|
|
|
|
html += '<paper-slider pin step=".1" min="0" max="100" value="0" class="videoPositionSlider"></paper-slider>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<div class="currentTime">--:--</div>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<paper-icon-button icon="volume-up" class="muteButton mediaButton" onclick="MediaPlayer.mute();"></paper-icon-button>';
|
|
|
|
|
html += '<paper-icon-button icon="volume-off" class="unmuteButton mediaButton" onclick="MediaPlayer.unMute();"></paper-icon-button>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<paper-slider pin step="1" min="0" max="100" value="0" class="videoVolumeSlider" style="width:100px;vertical-align:middle;margin-left:-1em;"></paper-slider>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '<paper-icon-button icon="fullscreen" class="mediaButton fullscreenButton" onclick="MediaPlayer.toggleFullscreen();" id="video-fullscreenButton"></paper-icon-button>';
|
2015-08-28 12:10:44 -07:00
|
|
|
|
html += '<paper-icon-button icon="info" class="mediaButton infoButton" onclick="MediaPlayer.toggleInfo();"></paper-icon-button>';
|
|
|
|
|
html += '</div>';
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '</div>'; // videoControls
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
html += '</div>'; // videoPlayer
|
|
|
|
|
html += '</div>'; // videoBackdrop
|
|
|
|
|
html += '</div>'; // mediaPlayer
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
var div = document.createElement('div');
|
|
|
|
|
div.innerHTML = html;
|
|
|
|
|
document.body.appendChild(div);
|
2015-07-03 04:51:45 -07:00
|
|
|
|
$(div).trigger('create');
|
2015-06-27 12:53:36 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.ready(function () {
|
|
|
|
|
|
|
|
|
|
ensureVideoPlayerElements();
|
|
|
|
|
|
|
|
|
|
var parent = $("#mediaPlayer");
|
|
|
|
|
|
|
|
|
|
muteButton = $('.muteButton', parent);
|
|
|
|
|
unmuteButton = $('.unmuteButton', parent);
|
|
|
|
|
currentTimeElement = $('.currentTime', parent);
|
|
|
|
|
|
|
|
|
|
positionSlider = $(".videoPositionSlider", parent).on('change', onPositionSliderChange)[0];
|
|
|
|
|
|
|
|
|
|
positionSlider._setPinValue = function (value) {
|
|
|
|
|
|
2015-09-09 10:49:44 -07:00
|
|
|
|
var seekableDuration = getSeekableDuration();
|
|
|
|
|
if (!self.currentMediaSource || !seekableDuration) {
|
2015-06-27 12:53:36 -07:00
|
|
|
|
this.pinValue = '--:--';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-09 10:49:44 -07:00
|
|
|
|
var ticks = seekableDuration;
|
2015-06-27 12:53:36 -07:00
|
|
|
|
ticks /= 100;
|
|
|
|
|
ticks *= value;
|
|
|
|
|
|
|
|
|
|
this.pinValue = Dashboard.getDisplayTime(ticks);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
volumeSlider = $('.videoVolumeSlider', parent).on('change', function () {
|
|
|
|
|
|
|
|
|
|
var vol = this.value;
|
|
|
|
|
|
|
|
|
|
updateVolumeButtons(vol);
|
|
|
|
|
self.setVolume(vol);
|
|
|
|
|
})[0];
|
2014-03-08 01:09:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
var idleHandlerTimeout;
|
2014-03-18 12:57:32 -07:00
|
|
|
|
function idleHandler() {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
if (idleHandlerTimeout) {
|
|
|
|
|
window.clearTimeout(idleHandlerTimeout);
|
2014-03-18 12:57:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (idleState == true) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.hiddenOnIdle').removeClass("inactive");
|
2014-10-09 15:22:04 -07:00
|
|
|
|
$('#videoPlayer').removeClass('idlePlayer');
|
2014-03-18 12:57:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idleState = false;
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
idleHandlerTimeout = window.setTimeout(function () {
|
2014-03-18 12:57:32 -07:00
|
|
|
|
idleState = true;
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.hiddenOnIdle').addClass("inactive");
|
2014-10-09 15:22:04 -07:00
|
|
|
|
$('#videoPlayer').addClass('idlePlayer');
|
2015-06-26 08:53:49 -07:00
|
|
|
|
}, 3500);
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-18 12:57:32 -07:00
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
function updateVolumeButtons(vol) {
|
|
|
|
|
|
|
|
|
|
if (vol) {
|
|
|
|
|
muteButton.show();
|
|
|
|
|
unmuteButton.hide();
|
|
|
|
|
} else {
|
|
|
|
|
muteButton.hide();
|
|
|
|
|
unmuteButton.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
function requestFullScreen(element) {
|
2014-03-20 12:12:10 -07:00
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
// Supports most browsers and their versions.
|
2015-05-17 18:27:48 -07:00
|
|
|
|
var requestMethod = element.requestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen || element.msRequestFullscreen;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (requestMethod) { // Native full screen.
|
|
|
|
|
requestMethod.call(element);
|
|
|
|
|
} else {
|
|
|
|
|
enterFullScreen();
|
|
|
|
|
}
|
2014-03-20 12:12:10 -07:00
|
|
|
|
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
function enterFullScreen() {
|
|
|
|
|
|
2014-03-17 07:48:16 -07:00
|
|
|
|
var player = $("#videoPlayer");
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
player.addClass("fullscreenVideo");
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
function exitFullScreenToWindow() {
|
|
|
|
|
|
2014-03-17 07:48:16 -07:00
|
|
|
|
var player = $("#videoPlayer");
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
player.removeClass("fullscreenVideo");
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function onPopState() {
|
|
|
|
|
// Stop playback on browser back button nav
|
|
|
|
|
self.stop();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function onBodyMouseMove() {
|
|
|
|
|
idleHandler();
|
|
|
|
|
}
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function onFullScreenChange() {
|
|
|
|
|
if (self.isFullScreen()) {
|
|
|
|
|
enterFullScreen();
|
|
|
|
|
idleState = true;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
exitFullScreenToWindow();
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
2015-06-29 11:45:42 -07:00
|
|
|
|
}
|
2014-07-03 19:22:57 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function bindEventsForPlayback(mediaRenderer) {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
var hideElementsOnIdle = true;
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
if (hideElementsOnIdle) {
|
|
|
|
|
|
|
|
|
|
var itemVideo = document.querySelector('.itemVideo');
|
|
|
|
|
if (itemVideo) {
|
|
|
|
|
Events.on(itemVideo, 'mousemove', idleHandler);
|
|
|
|
|
Events.on(itemVideo, 'keydown', idleHandler);
|
|
|
|
|
Events.on(itemVideo, 'scroll', idleHandler);
|
|
|
|
|
Events.on(itemVideo, 'mousedown', idleHandler);
|
|
|
|
|
idleHandler();
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
2015-06-29 11:45:42 -07:00
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(document).on('webkitfullscreenchange', onFullScreenChange);
|
|
|
|
|
$(document).on('mozfullscreenchange', onFullScreenChange);
|
|
|
|
|
$(document).on('msfullscreenchange', onFullScreenChange);
|
|
|
|
|
$(document).on('fullscreenchange', onFullScreenChange);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(window).one("popstate", onPopState);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
if (hideElementsOnIdle) {
|
|
|
|
|
$(document.body).on("mousemove", onBodyMouseMove);
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function unbindEventsForPlayback(mediaRenderer) {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(document).off('webkitfullscreenchange', onFullScreenChange);
|
|
|
|
|
$(document).off('mozfullscreenchange', onFullScreenChange);
|
|
|
|
|
$(document).off('msfullscreenchange', onFullScreenChange);
|
|
|
|
|
$(document).off('fullscreenchange', onFullScreenChange);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
|
|
|
|
// Stop playback on browser back button nav
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(window).off("popstate", onPopState);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(document.body).off("mousemove", onBodyMouseMove);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
var itemVideo = document.querySelector('.itemVideo');
|
|
|
|
|
if (itemVideo) {
|
|
|
|
|
Events.off(itemVideo, 'mousemove', idleHandler);
|
|
|
|
|
Events.off(itemVideo, 'keydown', idleHandler);
|
|
|
|
|
Events.off(itemVideo, 'scroll', idleHandler);
|
|
|
|
|
Events.off(itemVideo, 'mousedown', idleHandler);
|
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-10 15:13:17 -07:00
|
|
|
|
// Replace audio version
|
2015-06-07 13:06:18 -07:00
|
|
|
|
self.cleanup = function (mediaRenderer) {
|
2014-08-10 15:13:17 -07:00
|
|
|
|
|
2015-06-07 13:06:18 -07:00
|
|
|
|
currentTimeElement.html('--:--');
|
2014-08-10 15:13:17 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
unbindEventsForPlayback(mediaRenderer);
|
2014-08-10 15:13:17 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
self.playVideo = function (item, mediaSource, startPosition, callback) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-10 06:37:07 -07:00
|
|
|
|
requirejs(['videorenderer'], function () {
|
2015-03-26 11:23:46 -07:00
|
|
|
|
|
2015-06-07 20:16:42 -07:00
|
|
|
|
var streamInfo = self.createStreamInfo('Video', item, mediaSource, startPosition);
|
2015-04-28 06:56:57 -07:00
|
|
|
|
|
2015-06-07 20:16:42 -07:00
|
|
|
|
// Huge hack alert. Safari doesn't seem to like if the segments aren't available right away when playback starts
|
|
|
|
|
// This will start the transcoding process before actually feeding the video url into the player
|
|
|
|
|
if ($.browser.safari && !mediaSource.RunTimeTicks) {
|
2015-04-28 06:56:57 -07:00
|
|
|
|
|
2015-08-24 13:37:34 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2015-04-28 06:56:57 -07:00
|
|
|
|
|
2015-06-07 20:16:42 -07:00
|
|
|
|
ApiClient.ajax({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: streamInfo.url.replace('master.m3u8', 'live.m3u8')
|
2015-08-24 13:37:34 -07:00
|
|
|
|
}).always(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
2015-06-07 20:16:42 -07:00
|
|
|
|
}).done(function () {
|
2015-07-08 09:10:34 -07:00
|
|
|
|
self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback);
|
2015-06-07 20:16:42 -07:00
|
|
|
|
});
|
2015-04-28 06:56:57 -07:00
|
|
|
|
|
2015-06-07 20:16:42 -07:00
|
|
|
|
} else {
|
2015-07-08 09:10:34 -07:00
|
|
|
|
self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback);
|
2015-06-07 20:16:42 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2015-04-28 06:56:57 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
self.playVideoInternal = function (item, mediaSource, startPosition, streamInfo, callback) {
|
2015-04-28 06:56:57 -07:00
|
|
|
|
|
2015-03-26 11:23:46 -07:00
|
|
|
|
var videoUrl = streamInfo.url;
|
2015-07-30 18:52:11 -07:00
|
|
|
|
|
2015-03-26 11:23:46 -07:00
|
|
|
|
self.startTimeTicksOffset = streamInfo.startTimeTicksOffset;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-03-26 09:58:02 -07:00
|
|
|
|
var mediaStreams = mediaSource.MediaStreams || [];
|
2014-06-11 12:31:33 -07:00
|
|
|
|
var subtitleStreams = mediaStreams.filter(function (s) {
|
|
|
|
|
return s.Type == 'Subtitle';
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-18 18:46:31 -07:00
|
|
|
|
// Reports of stuttering with h264 stream copy in IE
|
|
|
|
|
if (streamInfo.playMethod == 'Transcode' && videoUrl.indexOf('.m3u8') == -1) {
|
2015-05-23 13:44:15 -07:00
|
|
|
|
videoUrl += '&EnableAutoStreamCopy=false';
|
2015-05-18 18:46:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 01:34:54 -07:00
|
|
|
|
// Create video player
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var mediaPlayerContainer = $("#mediaPlayer").show();
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var videoControls = $('.videoControls', mediaPlayerContainer);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
//show stop button
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$('#video-playButton', videoControls).hide();
|
|
|
|
|
$('#video-pauseButton', videoControls).show();
|
2015-07-08 09:10:34 -07:00
|
|
|
|
$('.videoTrackControl').visible(false);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-07-03 04:51:45 -07:00
|
|
|
|
var videoElement = $('#videoElement', mediaPlayerContainer);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoQualityButton', videoControls).show();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
if (mediaStreams.filter(function (s) {
|
|
|
|
|
return s.Type == "Audio";
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}).length) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoAudioButton').show();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoAudioButton').hide();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
if (subtitleStreams.length) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoSubtitleButton').show();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoSubtitleButton').hide();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-03 09:49:49 -07:00
|
|
|
|
var mediaRenderer = new VideoRenderer({
|
2015-09-09 20:22:52 -07:00
|
|
|
|
|
2015-07-03 09:49:49 -07:00
|
|
|
|
poster: self.getPosterUrl(item)
|
|
|
|
|
});
|
2015-07-03 04:51:45 -07:00
|
|
|
|
|
|
|
|
|
var requiresNativeControls = !mediaRenderer.enableCustomVideoControls();
|
|
|
|
|
|
2015-09-08 07:35:52 -07:00
|
|
|
|
if (requiresNativeControls || AppInfo.isNativeApp) {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$('#video-fullscreenButton', videoControls).hide();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else {
|
2015-09-08 07:35:52 -07:00
|
|
|
|
$('#video-fullscreenButton', videoControls).hide();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
if (AppInfo.hasPhysicalVolumeButtons) {
|
2015-06-27 12:53:36 -07:00
|
|
|
|
$(volumeSlider).visible(false);
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.muteButton', videoControls).addClass('hide');
|
|
|
|
|
$('.unmuteButton', videoControls).addClass('hide');
|
|
|
|
|
} else {
|
2015-06-27 12:53:36 -07:00
|
|
|
|
$(volumeSlider).visible(true);
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.muteButton', videoControls).removeClass('hide');
|
|
|
|
|
$('.unmuteButton', videoControls).removeClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (requiresNativeControls) {
|
|
|
|
|
videoControls.addClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
videoControls.removeClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
initialVolume = self.getSavedVolume();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-07 13:06:18 -07:00
|
|
|
|
mediaRenderer.volume(initialVolume);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
volumeSlider.value = initialVolume * 100;
|
2014-04-11 08:36:25 -07:00
|
|
|
|
updateVolumeButtons(initialVolume);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-07 13:06:18 -07:00
|
|
|
|
$(mediaRenderer).on("volumechange.mediaplayerevent", function (e) {
|
2014-10-07 18:37:45 -07:00
|
|
|
|
|
2015-06-07 13:06:18 -07:00
|
|
|
|
updateVolumeButtons(this.volume());
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).one("playing.mediaplayerevent", function () {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-08-10 15:13:17 -07:00
|
|
|
|
// For some reason this is firing at the start, so don't bind until playback has begun
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(this).on("ended", self.onPlaybackStopped).one('ended', self.playNextAfterEnded);
|
2014-08-10 15:13:17 -07:00
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
self.onPlaybackStart(this, item, mediaSource);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on("pause.mediaplayerevent", function (e) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$('#video-playButton', videoControls).show();
|
|
|
|
|
$('#video-pauseButton', videoControls).hide();
|
|
|
|
|
$("#pause", videoElement).show().addClass("fadeOut");
|
2014-03-08 01:09:45 -07:00
|
|
|
|
setTimeout(function () {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$("#pause", videoElement).hide().removeClass("fadeOut");
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}, 300);
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on("playing.mediaplayerevent", function (e) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$('#video-playButton', videoControls).hide();
|
|
|
|
|
$('#video-pauseButton', videoControls).show();
|
|
|
|
|
$("#play", videoElement).show().addClass("fadeOut");
|
2014-03-08 01:09:45 -07:00
|
|
|
|
setTimeout(function () {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$("#play", videoElement).hide().removeClass("fadeOut");
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}, 300);
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on("timeupdate.mediaplayerevent", function () {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
if (!positionSlider.dragging) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
self.setCurrentTime(self.getCurrentTicks(this), positionSlider, currentTimeElement);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on("error.mediaplayerevent", function () {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
var errorMsg = Globalize.translate('MessageErrorPlayingVideo');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-17 18:45:28 -07:00
|
|
|
|
if (item.Type == "TvChannel") {
|
2014-07-21 18:29:06 -07:00
|
|
|
|
errorMsg += '<p>';
|
|
|
|
|
errorMsg += Globalize.translate('MessageEnsureOpenTuner');
|
|
|
|
|
errorMsg += '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
Dashboard.alert({
|
2014-07-21 18:29:06 -07:00
|
|
|
|
title: Globalize.translate('HeaderVideoError'),
|
2014-03-08 01:09:45 -07:00
|
|
|
|
message: errorMsg
|
|
|
|
|
});
|
|
|
|
|
|
2015-08-27 08:58:07 -07:00
|
|
|
|
self.onPlaybackStopped.call(mediaRenderer);
|
|
|
|
|
self.nextTrack();
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on("click.mediaplayerevent", function (e) {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
|
2015-05-26 08:31:50 -07:00
|
|
|
|
if (!$.browser.mobile) {
|
2015-06-07 13:06:18 -07:00
|
|
|
|
if (this.paused()) {
|
2015-05-26 08:31:50 -07:00
|
|
|
|
self.unpause();
|
|
|
|
|
} else {
|
|
|
|
|
self.pause();
|
|
|
|
|
}
|
2014-03-20 01:34:54 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on("dblclick.mediaplayerevent", function () {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
|
2015-05-26 08:31:50 -07:00
|
|
|
|
if (!$.browser.mobile) {
|
|
|
|
|
self.toggleFullscreen();
|
|
|
|
|
}
|
2014-08-10 15:13:17 -07:00
|
|
|
|
});
|
2014-03-20 01:34:54 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
bindEventsForPlayback(mediaRenderer);
|
2014-03-20 01:34:54 -07:00
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
self.currentSubtitleStreamIndex = mediaSource.DefaultSubtitleStreamIndex;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-06-27 12:53:36 -07:00
|
|
|
|
$(document.body).addClass('bodyWithPopupOpen');
|
2014-06-28 12:35:30 -07:00
|
|
|
|
|
2015-06-07 13:06:18 -07:00
|
|
|
|
self.currentMediaRenderer = mediaRenderer;
|
2015-04-28 06:56:57 -07:00
|
|
|
|
self.currentDurationTicks = self.currentMediaSource.RunTimeTicks;
|
|
|
|
|
|
|
|
|
|
self.updateNowPlayingInfo(item);
|
2015-07-03 04:51:45 -07:00
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
mediaRenderer.init().done(function () {
|
2015-07-03 09:49:49 -07:00
|
|
|
|
|
2015-07-30 18:52:11 -07:00
|
|
|
|
self.setSrcIntoRenderer(mediaRenderer, videoUrl, item, self.currentMediaSource);
|
2015-07-03 04:51:45 -07:00
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
if (callback) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
2015-07-03 04:51:45 -07:00
|
|
|
|
});
|
2014-06-21 22:52:31 -07:00
|
|
|
|
};
|
2015-03-13 01:58:50 -07:00
|
|
|
|
|
|
|
|
|
self.updatePlaylistUi = function () {
|
2015-05-27 22:51:48 -07:00
|
|
|
|
var index = self.currentPlaylistIndex(null);
|
|
|
|
|
var length = self.playlist.length;
|
2015-07-03 04:51:45 -07:00
|
|
|
|
|
|
|
|
|
var requiresNativeControls = false;
|
|
|
|
|
|
2015-09-10 11:28:22 -07:00
|
|
|
|
if (self.currentMediaRenderer && self.currentMediaRenderer.enableCustomVideoControls) {
|
2015-07-03 04:51:45 -07:00
|
|
|
|
requiresNativeControls = self.currentMediaRenderer.enableCustomVideoControls();
|
|
|
|
|
}
|
2015-03-23 10:19:21 -07:00
|
|
|
|
|
2015-03-13 01:58:50 -07:00
|
|
|
|
if (length < 2) {
|
2015-07-08 09:10:34 -07:00
|
|
|
|
$('.videoTrackControl').visible(false);
|
2015-03-13 01:58:50 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var controls = requiresNativeControls ? '.videoAdvancedControls' : '.videoControls';
|
2015-06-29 11:45:42 -07:00
|
|
|
|
controls = document.querySelector(controls);
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
|
|
|
|
var previousTrackButton = controls.getElementsByClassName('previousTrackButton')[0];
|
|
|
|
|
var nextTrackButton = controls.getElementsByClassName('nextTrackButton')[0];
|
|
|
|
|
|
2015-03-13 01:58:50 -07:00
|
|
|
|
if (index === 0) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
previousTrackButton.setAttribute('disabled', 'disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
previousTrackButton.removeAttribute('disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((index + 1) >= length) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
nextTrackButton.setAttribute('disabled', 'disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
nextTrackButton.removeAttribute('disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 09:10:34 -07:00
|
|
|
|
$(previousTrackButton).visible(true);
|
|
|
|
|
$(nextTrackButton).visible(true);
|
2015-03-13 01:58:50 -07:00
|
|
|
|
};
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createVideoPlayer(MediaPlayer);
|
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
})();
|