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
|
|
|
|
|
|
|
|
|
var timeout;
|
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 isPositionSliderActive;
|
|
|
|
|
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 () {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$("#mediaPlayer").hide();
|
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();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
function onFlyoutClose() {
|
|
|
|
|
$('.itemVideo').css('visibility', 'visible');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPopupOpen(elem) {
|
|
|
|
|
elem.popup("open").parents(".ui-popup-container").css("margin-top", 30);
|
|
|
|
|
|
|
|
|
|
if ($.browser.safari) {
|
2015-06-01 07:49:23 -07:00
|
|
|
|
//$('.itemVideo').css('visibility', 'hidden');
|
2014-07-02 11:34:08 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
self.showChaptersFlyout = function () {
|
|
|
|
|
|
|
|
|
|
var html = getChaptersFlyoutHtml();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
var elem = $('.videoChaptersPopup').html(html)
|
2014-06-28 12:35:30 -07:00
|
|
|
|
.trigger('create')
|
2015-05-21 13:53:14 -07:00
|
|
|
|
.popup("option", "positionTo", $('.videoChaptersButton'))
|
2014-07-02 11:34:08 -07:00
|
|
|
|
.off('popupafterclose', onFlyoutClose)
|
|
|
|
|
.on('popupafterclose', onFlyoutClose);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
onPopupOpen(elem);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
self.showSubtitleMenu = function () {
|
|
|
|
|
|
|
|
|
|
var html = getSubtitleTracksHtml();
|
|
|
|
|
|
|
|
|
|
var elem = $('.videoSubtitlePopup').html(html)
|
2014-06-28 12:35:30 -07:00
|
|
|
|
.trigger('create')
|
2015-05-21 13:53:14 -07:00
|
|
|
|
.popup("option", "positionTo", $('.videoSubtitleButton'))
|
2014-07-02 11:34:08 -07:00
|
|
|
|
.off('popupafterclose', onFlyoutClose)
|
|
|
|
|
.on('popupafterclose', onFlyoutClose);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
onPopupOpen(elem);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
self.showQualityFlyout = function () {
|
|
|
|
|
|
|
|
|
|
var html = getQualityFlyoutHtml();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
var elem = $('.videoQualityPopup').html(html)
|
2014-06-28 12:35:30 -07:00
|
|
|
|
.trigger('create')
|
2015-05-21 13:53:14 -07:00
|
|
|
|
.popup("option", "positionTo", $('.videoQualityButton'))
|
2014-07-02 11:34:08 -07:00
|
|
|
|
.off('popupafterclose', onFlyoutClose)
|
|
|
|
|
.on('popupafterclose', onFlyoutClose);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
onPopupOpen(elem);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.showAudioTracksFlyout = function () {
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
var html = getAudioTracksHtml();
|
|
|
|
|
|
|
|
|
|
var elem = $('.videoAudioPopup').html(html)
|
2014-06-28 12:35:30 -07:00
|
|
|
|
.trigger('create')
|
2014-07-02 11:34:08 -07:00
|
|
|
|
.popup("option", "positionTo", $('.videoAudioButton'))
|
|
|
|
|
.off('popupafterclose', onFlyoutClose)
|
|
|
|
|
.on('popupafterclose', onFlyoutClose);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
onPopupOpen(elem);
|
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
|
|
|
|
|
|
|
|
|
if (!self.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) {
|
|
|
|
|
|
2014-08-25 19:30:52 -07:00
|
|
|
|
var modes = ['disabled', 'showing', 'hidden'];
|
|
|
|
|
|
2014-06-11 19:38:40 -07:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
console.log('Setting new text track index to: ' + trackIndex);
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var allTracks = self.currentMediaElement.textTracks; // get list of tracks
|
2014-06-11 19:38:40 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0; i < allTracks.length; i++) {
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var mode;
|
2014-06-11 19:38:40 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (trackIndex == i) {
|
2014-08-25 19:30:52 -07:00
|
|
|
|
mode = 1; // show this track
|
2014-06-11 19:38:40 -07:00
|
|
|
|
} else {
|
2014-08-25 19:30:52 -07:00
|
|
|
|
mode = 0; // hide all other tracks
|
2014-06-11 19:38:40 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
console.log('Setting track ' + i + ' mode to: ' + mode);
|
2014-08-25 19:30:52 -07:00
|
|
|
|
|
|
|
|
|
// Safari uses integers for the mode property
|
|
|
|
|
// http://www.jwplayer.com/html5/scripting/
|
|
|
|
|
var useNumericMode = false;
|
|
|
|
|
|
|
|
|
|
if (!isNaN(allTracks[i].mode)) {
|
|
|
|
|
useNumericMode = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useNumericMode) {
|
|
|
|
|
allTracks[i].mode = mode;
|
|
|
|
|
} else {
|
|
|
|
|
allTracks[i].mode = modes[mode];
|
|
|
|
|
}
|
2014-06-11 19:38:40 -07:00
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
};
|
|
|
|
|
|
2014-06-14 19:58:00 -07:00
|
|
|
|
self.updateTextStreamUrls = function (startPositionTicks) {
|
|
|
|
|
|
2014-06-15 16:30:04 -07:00
|
|
|
|
if (!self.supportsTextTracks()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var allTracks = self.currentMediaElement.textTracks; // get list of tracks
|
2014-06-18 09:08:54 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0; i < allTracks.length; i++) {
|
|
|
|
|
|
|
|
|
|
var track = allTracks[i];
|
|
|
|
|
|
|
|
|
|
// This throws an error in IE, but is fine in chrome
|
|
|
|
|
// In IE it's not necessary anyway because changing the src seems to be enough
|
|
|
|
|
try {
|
|
|
|
|
while (track.cues.length) {
|
|
|
|
|
track.removeCue(track.cues[0]);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log('Error removing cue from textTrack');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
$('track', self.currentMediaElement).each(function () {
|
2014-06-14 19:58:00 -07:00
|
|
|
|
|
|
|
|
|
var currentSrc = this.src;
|
|
|
|
|
|
|
|
|
|
currentSrc = replaceQueryString(currentSrc, 'startPositionTicks', startPositionTicks);
|
|
|
|
|
|
|
|
|
|
this.src = currentSrc;
|
2014-06-15 16:30:04 -07:00
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
var state = self.getPlayerStateInternal(self.currentMediaElement, item, self.currentMediaSource);
|
|
|
|
|
|
|
|
|
|
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-05-13 20:24:25 -07:00
|
|
|
|
var elem = $('.nowPlayingTabs', mediaControls).html(getNowPlayingTabsHtml(item)).lazyChildren();
|
|
|
|
|
|
|
|
|
|
$('.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-05-27 22:51:48 -07:00
|
|
|
|
var width = 320;
|
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-05-27 22:51:48 -07:00
|
|
|
|
var height = 160;
|
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
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
imgUrl = "css/images/items/list/person.png";
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-27 22:51:48 -07:00
|
|
|
|
personHtml += '<div class="tileImage lazy" data-src="' + imgUrl + '" style="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
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
function onPositionSliderChange() {
|
|
|
|
|
|
|
|
|
|
isPositionSliderActive = false;
|
|
|
|
|
|
|
|
|
|
var newPercent = parseInt(this.value);
|
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
var newPositionTicks = (newPercent / 100) * self.currentMediaSource.RunTimeTicks;
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
|
|
|
|
self.changeStream(Math.floor(newPositionTicks));
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
self.onChapterOptionSelected = function (elem) {
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
if (!$(elem).hasClass('selectedMediaPopupOption')) {
|
|
|
|
|
var ticks = parseInt(elem.getAttribute('data-value') || '0');
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
self.changeStream(ticks);
|
|
|
|
|
}
|
|
|
|
|
$('.videoChaptersPopup').popup('close');
|
|
|
|
|
};
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
self.onAudioOptionSelected = function (elem) {
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
if (!$(elem).hasClass('selectedMediaPopupOption')) {
|
|
|
|
|
var index = parseInt(elem.getAttribute('data-value'));
|
|
|
|
|
|
|
|
|
|
self.setAudioStreamIndex(index);
|
|
|
|
|
}
|
|
|
|
|
$('.videoAudioPopup').popup('close');
|
|
|
|
|
};
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
self.onSubtitleOptionSelected = function (elem) {
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
if (!$(elem).hasClass('selectedMediaPopupOption')) {
|
|
|
|
|
var index = parseInt(elem.getAttribute('data-value'));
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
self.setSubtitleStreamIndex(index);
|
|
|
|
|
}
|
|
|
|
|
$('.videoSubtitlePopup').popup('close');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.onQualityOptionSelected = function (elem) {
|
|
|
|
|
|
|
|
|
|
if (!$(elem).hasClass('selectedMediaPopupOption')) {
|
|
|
|
|
var bitrate = parseInt(elem.getAttribute('data-value'));
|
|
|
|
|
|
|
|
|
|
AppSettings.maxStreamingBitrate(bitrate);
|
|
|
|
|
|
|
|
|
|
$('.videoQualityPopup').popup('close');
|
|
|
|
|
|
|
|
|
|
self.changeStream(self.getCurrentTicks(), {
|
|
|
|
|
Bitrate: bitrate
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.videoSubtitlePopup').popup('close');
|
|
|
|
|
};
|
2015-05-21 13:53:14 -07:00
|
|
|
|
|
2014-03-08 01:09:45 -07:00
|
|
|
|
$(function () {
|
2014-04-11 08:36:25 -07:00
|
|
|
|
|
|
|
|
|
var parent = $("#mediaPlayer");
|
|
|
|
|
muteButton = $('.muteButton', parent);
|
|
|
|
|
unmuteButton = $('.unmuteButton', parent);
|
|
|
|
|
currentTimeElement = $('.currentTime', parent);
|
|
|
|
|
|
|
|
|
|
positionSlider = $(".positionSlider", parent).on('slidestart', function (e) {
|
|
|
|
|
|
|
|
|
|
isPositionSliderActive = true;
|
|
|
|
|
|
|
|
|
|
}).on('slidestop', onPositionSliderChange);
|
|
|
|
|
|
|
|
|
|
volumeSlider = $('.volumeSlider', parent).on('slidestop', function () {
|
|
|
|
|
|
|
|
|
|
var vol = this.value;
|
|
|
|
|
|
|
|
|
|
updateVolumeButtons(vol);
|
|
|
|
|
self.setVolume(vol * 100);
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-31 14:39:12 -07:00
|
|
|
|
var trackChange = false;
|
|
|
|
|
|
|
|
|
|
var tooltip = $('<div id="slider-tooltip"></div>');
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$(".videoControls .positionSliderContainer .slider").on("change", function (e) {
|
2014-03-31 14:39:12 -07:00
|
|
|
|
if (!trackChange) return;
|
|
|
|
|
|
|
|
|
|
var pct = $(this).val();
|
|
|
|
|
|
2014-03-31 14:43:49 -07:00
|
|
|
|
var time = self.currentDurationTicks * (Number(pct) * .01);
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
2014-06-17 22:15:51 -07:00
|
|
|
|
var tooltext = Dashboard.getDisplayTime(time);
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
|
|
|
|
tooltip.text(tooltext);
|
|
|
|
|
|
2014-03-31 14:43:49 -07:00
|
|
|
|
console.log("slidin", pct, self.currentDurationTicks, time);
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
|
|
|
|
}).on("slidestart", function (e) {
|
|
|
|
|
trackChange = true;
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var handle = $(".videoControls .positionSliderContainer .ui-slider-handle");
|
2014-03-31 14:39:12 -07:00
|
|
|
|
|
|
|
|
|
handle.after(tooltip);
|
|
|
|
|
}).on("slidestop", function (e) {
|
|
|
|
|
trackChange = false;
|
|
|
|
|
|
|
|
|
|
tooltip.remove();
|
|
|
|
|
});
|
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-05-27 22:51:48 -07:00
|
|
|
|
}, 4000);
|
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
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
function getChaptersFlyoutHtml() {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var item = self.currentItem;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
var currentTicks = self.getCurrentTicks();
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var chapters = item.Chapters || [];
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
html += '<div class="videoPlayerPopupContent">';
|
2014-07-02 11:34:08 -07:00
|
|
|
|
html += '<ul data-role="listview" data-inset="true"><li data-role="list-divider">' + Globalize.translate('HeaderScenes') + '</li>';
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '</ul>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '<div class="videoPlayerPopupScroller">';
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var index = 0;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += chapters.map(function (chapter) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var cssClass = "mediaPopupOption";
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var selected = false;
|
2015-05-22 13:15:29 -07:00
|
|
|
|
// Need to embed onclick handler due to delegation not working in iOS cordova
|
|
|
|
|
var onclick = '';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (currentTicks >= chapter.StartPositionTicks) {
|
|
|
|
|
var nextChapter = chapters[index + 1];
|
|
|
|
|
selected = !nextChapter || currentTicks < nextChapter.StartPositionTicks;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
if (!selected) {
|
|
|
|
|
onclick = ' onclick="MediaPlayer.onChapterOptionSelected(this);"';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var optionHtml = '<li><a' + onclick + ' data-value="' + chapter.StartPositionTicks + '" class="' + cssClass + '" href="#" style="padding-top:0;padding-bottom:0;">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var imgUrl = "css/images/media/chapterflyout.png";
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (chapter.ImageTag) {
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<img src="' + imgUrl + '" style="visibility:hidden;" />';
|
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
width: 160,
|
2014-03-08 01:09:45 -07:00
|
|
|
|
tag: chapter.ImageTag,
|
|
|
|
|
type: "Chapter",
|
2014-06-28 12:35:30 -07:00
|
|
|
|
index: index
|
2014-03-08 01:09:45 -07:00
|
|
|
|
});
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<div class="videoChapterPopupImage" style="background-image:url(\'' + imgUrl + '\');"></div>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<img src="' + imgUrl + '" />';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
// TODO: Add some indicator if selected = true
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<p style="margin:12px 0 0;">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var textLines = [];
|
|
|
|
|
textLines.push(chapter.Name);
|
|
|
|
|
textLines.push(Dashboard.getDisplayTime(chapter.StartPositionTicks));
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += textLines.join('<br/>');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '</p>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '</a></li>';
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
return optionHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
return html;
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
function getAudioTracksHtml() {
|
2014-04-06 10:53:23 -07:00
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
var streams = self.currentMediaSource.MediaStreams.filter(function (currentStream) {
|
2014-03-20 20:31:40 -07:00
|
|
|
|
return currentStream.Type == "Audio";
|
2014-03-08 01:09:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-10-22 21:26:01 -07:00
|
|
|
|
var currentIndex = getParameterByName('AudioStreamIndex', self.getCurrentSrc(self.currentMediaElement));
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '<div class="videoPlayerPopupContent">';
|
2014-07-02 11:34:08 -07:00
|
|
|
|
html += '<ul data-role="listview" data-inset="true"><li data-role="list-divider">' + Globalize.translate('HeaderAudioTracks') + '</li>';
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '</ul>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '<div class="videoPlayerPopupScroller">';
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += streams.map(function (stream) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var cssClass = "mediaPopupOption";
|
|
|
|
|
|
|
|
|
|
var selected = stream.Index == currentIndex;
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
// Need to embed onclick handler due to delegation not working in iOS cordova
|
|
|
|
|
var onclick = '';
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (selected) {
|
|
|
|
|
cssClass += ' selectedMediaPopupOption';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
} else {
|
|
|
|
|
onclick = ' onclick="MediaPlayer.onAudioOptionSelected(this);"';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
var optionHtml = '<li><a' + onclick + ' data-value="' + stream.Index + '" class="' + cssClass + '" href="#">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<p style="margin:0;">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (selected) {
|
|
|
|
|
optionHtml += '<img src="css/images/checkmarkgreen.png" style="width:18px;border-radius:3px;margin-right:.5em;vertical-align:middle;" />';
|
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var textLines = [];
|
2014-07-02 11:34:08 -07:00
|
|
|
|
textLines.push(stream.Language || Globalize.translate('LabelUnknownLanguage'));
|
2014-06-28 12:35:30 -07:00
|
|
|
|
|
|
|
|
|
var attributes = [];
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (stream.Codec) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push(stream.Codec);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
if (stream.Profile) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push(stream.Profile);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stream.BitRate) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push((Math.floor(stream.BitRate / 1000)) + ' kbps');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stream.Channels) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push(stream.Channels + ' ch');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stream.IsDefault) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push('(D)');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (attributes.length) {
|
|
|
|
|
textLines.push(attributes.join(' • '));
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += textLines.join('<br/>');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '</p>';
|
|
|
|
|
|
|
|
|
|
optionHtml += '</a></li>';
|
|
|
|
|
|
|
|
|
|
return optionHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
return html;
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
function getSubtitleTracksHtml() {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-11 12:31:33 -07:00
|
|
|
|
var streams = self.currentMediaSource.MediaStreams.filter(function (currentStream) {
|
2014-03-20 20:31:40 -07:00
|
|
|
|
return currentStream.Type == "Subtitle";
|
2014-03-08 01:09:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-06-11 19:38:40 -07:00
|
|
|
|
var currentIndex = self.currentSubtitleStreamIndex || -1;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
streams.unshift({
|
|
|
|
|
Index: -1,
|
|
|
|
|
Language: "Off"
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
html += '<div class="videoPlayerPopupContent">';
|
2014-07-02 11:34:08 -07:00
|
|
|
|
html += '<ul data-role="listview" data-inset="true"><li data-role="list-divider">' + Globalize.translate('HeaderSubtitles') + '</li>';
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '</ul>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '<div class="videoPlayerPopupScroller">';
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += streams.map(function (stream) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var cssClass = "mediaPopupOption";
|
|
|
|
|
|
|
|
|
|
var selected = stream.Index == currentIndex;
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
// Need to embed onclick handler due to delegation not working in iOS cordova
|
|
|
|
|
var onclick = '';
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (selected) {
|
|
|
|
|
cssClass += ' selectedMediaPopupOption';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
} else {
|
|
|
|
|
onclick = ' onclick="MediaPlayer.onSubtitleOptionSelected(this);"';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
var optionHtml = '<li><a' + onclick + ' data-value="' + stream.Index + '" class="' + cssClass + '" href="#">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<p style="margin:0;">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (selected) {
|
|
|
|
|
optionHtml += '<img src="css/images/checkmarkgreen.png" style="width:18px;border-radius:3px;margin-right:.5em;vertical-align:middle;" />';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var textLines = [];
|
2014-07-02 11:34:08 -07:00
|
|
|
|
textLines.push(stream.Language || Globalize.translate('LabelUnknownLanguage'));
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (stream.Codec) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
textLines.push(stream.Codec);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var attributes = [];
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (stream.IsDefault) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push('Default');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
if (stream.IsForced) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push('Forced');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
if (stream.IsExternal) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
attributes.push('External');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (attributes.length) {
|
|
|
|
|
textLines.push(attributes.join(' • '));
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += textLines.join('<br/>');
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '</p>';
|
|
|
|
|
|
|
|
|
|
optionHtml += '</a></li>';
|
|
|
|
|
|
|
|
|
|
return optionHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
return html;
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-03-20 20:31:40 -07:00
|
|
|
|
function getQualityFlyoutHtml() {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-10-22 21:26:01 -07:00
|
|
|
|
var currentSrc = self.getCurrentSrc(self.currentMediaElement).toLowerCase();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
var isStatic = currentSrc.indexOf('static=true') != -1;
|
|
|
|
|
|
2015-03-26 09:58:02 -07:00
|
|
|
|
var videoStream = self.currentMediaSource.MediaStreams.filter(function (stream) {
|
|
|
|
|
return stream.Type == "Video";
|
|
|
|
|
})[0];
|
|
|
|
|
var videoWidth = videoStream ? videoStream.Width : null;
|
|
|
|
|
|
|
|
|
|
var options = self.getVideoQualityOptions(videoWidth);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (isStatic) {
|
|
|
|
|
options[0].name = "Direct";
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var html = '';
|
2014-07-02 11:34:08 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '<div class="videoPlayerPopupContent">';
|
2014-07-02 11:34:08 -07:00
|
|
|
|
html += '<ul data-role="listview" data-inset="true"><li data-role="list-divider">' + Globalize.translate('HeaderVideoQuality') + '</li>';
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += '</ul>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="videoPlayerPopupScroller">';
|
|
|
|
|
html += '<ul data-role="listview" data-inset="true">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
html += options.map(function (option) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
var cssClass = "mediaPopupOption";
|
2015-05-22 13:15:29 -07:00
|
|
|
|
// Need to embed onclick handler due to delegation not working in iOS cordova
|
|
|
|
|
var onclick = '';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
if (option.selected) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
cssClass += ' selectedMediaPopupOption';
|
2015-05-22 13:15:29 -07:00
|
|
|
|
} else {
|
|
|
|
|
onclick = ' onclick="MediaPlayer.onQualityOptionSelected(this);"';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 13:15:29 -07:00
|
|
|
|
var optionHtml = '<li><a' + onclick + ' data-value="' + option.bitrate + '" class="' + cssClass + '" href="#">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '<p style="margin:0;">';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (option.selected) {
|
|
|
|
|
optionHtml += '<img src="css/images/checkmarkgreen.png" style="width:18px;border-radius:3px;margin-right:.5em;vertical-align:middle;" />';
|
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += option.name;
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
optionHtml += '</p>';
|
|
|
|
|
|
|
|
|
|
optionHtml += '</a></li>';
|
|
|
|
|
|
|
|
|
|
return optionHtml;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
html += '</ul>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
return html;
|
2014-04-06 19:06:09 -07:00
|
|
|
|
}
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
function bindEventsForPlayback() {
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
var hideElementsOnIdle = true;
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
if (hideElementsOnIdle) {
|
2015-05-25 10:32:22 -07:00
|
|
|
|
$('.itemVideo').off('mousemove.videoplayer keydown.videoplayer scroll.videoplayer mousedown.videoplayer', idleHandler).on('mousemove.videoplayer keydown.videoplayer scroll.videoplayer mousedown.videoplayer', idleHandler).trigger('mousemove');
|
2014-07-03 19:22:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-17 18:27:48 -07:00
|
|
|
|
$(document).on('webkitfullscreenchange.videoplayer mozfullscreenchange.videoplayer msfullscreenchange.videoplayer fullscreenchange.videoplayer', function (e) {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
|
|
|
|
if (self.isFullScreen()) {
|
|
|
|
|
enterFullScreen();
|
|
|
|
|
idleState = true;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
exitFullScreenToWindow();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Stop playback on browser back button nav
|
|
|
|
|
$(window).one("popstate.videoplayer", function () {
|
|
|
|
|
self.stop();
|
|
|
|
|
return;
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
if (hideElementsOnIdle) {
|
2015-05-13 20:24:25 -07:00
|
|
|
|
$(document.body).on("mousemove.videoplayer", function () {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
idleHandler(this);
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function unbindEventsForPlayback() {
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
$(document).off('.videoplayer');
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
|
|
|
|
// Stop playback on browser back button nav
|
|
|
|
|
$(window).off("popstate.videoplayer");
|
|
|
|
|
|
2015-05-13 20:24:25 -07:00
|
|
|
|
$(document.body).off("mousemove.videoplayer");
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
$('.itemVideo').off('mousemove.videoplayer keydown.videoplayer scroll.videoplayer mousedown.videoplayer');
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
self.canAutoPlayVideo = function () {
|
|
|
|
|
|
2015-05-28 16:37:43 -07:00
|
|
|
|
if (AppInfo.isNativeApp) {
|
2015-05-02 09:34:27 -07:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-13 20:24:25 -07:00
|
|
|
|
if ($.browser.mobile) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-02 09:34:27 -07:00
|
|
|
|
self.enableCustomVideoControls = function () {
|
|
|
|
|
|
|
|
|
|
return self.canAutoPlayVideo() && !$.browser.mobile;
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-10 15:13:17 -07:00
|
|
|
|
// Replace audio version
|
|
|
|
|
self.cleanup = function (playerElement) {
|
|
|
|
|
|
|
|
|
|
if (playerElement.tagName.toLowerCase() == 'video') {
|
|
|
|
|
currentTimeElement.html('--:--');
|
|
|
|
|
|
|
|
|
|
unbindEventsForPlayback();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-28 21:56:39 -07:00
|
|
|
|
self.playVideo = function (item, mediaSource, startPosition) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-04-07 21:01:52 -07:00
|
|
|
|
var streamInfo = self.createStreamInfo('Video', item, mediaSource, startPosition);
|
2015-03-26 11:23:46 -07:00
|
|
|
|
|
2015-04-28 06:56:57 -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) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.ajax({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: streamInfo.url.replace('master.m3u8', 'live.m3u8')
|
|
|
|
|
}).always(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
}).done(function () {
|
|
|
|
|
self.playVideoInternal(item, mediaSource, startPosition, streamInfo);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
self.playVideoInternal(item, mediaSource, startPosition, streamInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
function supportsContentOverVideoPlayer() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 06:56:57 -07:00
|
|
|
|
self.playVideoInternal = function (item, mediaSource, startPosition, streamInfo) {
|
|
|
|
|
|
2015-03-26 11:23:46 -07:00
|
|
|
|
var videoUrl = streamInfo.url;
|
2015-05-25 10:32:22 -07:00
|
|
|
|
var contentType = streamInfo.mimeType;
|
2015-03-26 11:23:46 -07:00
|
|
|
|
var startPositionInSeekParam = streamInfo.startPositionInSeekParam;
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 20:48:43 -07:00
|
|
|
|
var posterCode = self.getPosterUrl(item);
|
|
|
|
|
posterCode = posterCode ? (' poster="' + posterCode + '"') : '';
|
2014-06-28 12:35:30 -07:00
|
|
|
|
//======================================================================================>
|
2014-03-20 01:34:54 -07:00
|
|
|
|
|
|
|
|
|
// Create video player
|
2014-03-08 01:09:45 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-05-02 09:34:27 -07:00
|
|
|
|
var requiresNativeControls = !self.enableCustomVideoControls();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
// Can't autoplay in these browsers so we need to use the full controls
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (requiresNativeControls) {
|
2015-06-01 22:46:06 -07:00
|
|
|
|
html += '<video data-viblast-key="N8FjNTQ3NDdhZqZhNGI5NWU5ZTI=" class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="anonymous" controls="controls"' + posterCode + ' webkit-playsinline>';
|
2015-04-28 06:56:57 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2014-04-14 20:54:52 -07:00
|
|
|
|
// Chrome 35 won't play with preload none
|
2015-06-01 22:46:06 -07:00
|
|
|
|
html += '<video data-viblast-key="N8FjNTQ3NDdhZqZhNGI5NWU5ZTI=" class="itemVideo" id="itemVideo" preload="metadata" crossorigin="anonymous" autoplay' + posterCode + '>';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-26 09:58:02 -07:00
|
|
|
|
html += '<source type="' + contentType + '" src="' + videoUrl + '" />';
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
var textStreams = subtitleStreams.filter(function (s) {
|
|
|
|
|
return s.DeliveryMethod == 'External';
|
|
|
|
|
});
|
2014-06-11 12:31:33 -07:00
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
for (var i = 0, length = textStreams.length; i < length; i++) {
|
2014-06-11 12:31:33 -07:00
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
var textStream = textStreams[i];
|
2015-04-01 19:47:59 -07:00
|
|
|
|
var textStreamUrl = !textStream.IsExternalUrl ? ApiClient.getUrl(textStream.DeliveryUrl) : textStream.DeliveryUrl;
|
2015-03-30 12:57:37 -07:00
|
|
|
|
var defaultAttribute = textStream.Index == mediaSource.DefaultSubtitleStreamIndex ? ' default' : '';
|
2014-06-11 12:31:33 -07:00
|
|
|
|
|
2015-03-30 12:57:37 -07:00
|
|
|
|
html += '<track kind="subtitles" src="' + textStreamUrl + '" srclang="' + (textStream.Language || 'und') + '"' + defaultAttribute + '></track>';
|
2014-06-11 12:31:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 01:34:54 -07:00
|
|
|
|
html += '</video>';
|
|
|
|
|
|
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-03-13 23:24:42 -07:00
|
|
|
|
$('.videoTrackControl').hide();
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
|
|
|
|
var videoElement = $('#videoElement', mediaPlayerContainer).prepend(html);
|
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-05-21 13:53:14 -07:00
|
|
|
|
if (item.Chapters && item.Chapters.length && supportsContentOverVideoPlayer()) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoChaptersButton').show();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.videoChaptersButton').hide();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (requiresNativeControls) {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$('#video-fullscreenButton', videoControls).hide();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
} else {
|
2014-03-20 01:34:54 -07:00
|
|
|
|
$('#video-fullscreenButton', videoControls).show();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-21 13:53:14 -07:00
|
|
|
|
if (AppInfo.hasPhysicalVolumeButtons) {
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('.volumeSliderContainer', videoControls).addClass('hide');
|
|
|
|
|
$('.muteButton', videoControls).addClass('hide');
|
|
|
|
|
$('.unmuteButton', videoControls).addClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
$('.volumeSliderContainer', videoControls).removeClass('hide');
|
|
|
|
|
$('.muteButton', videoControls).removeClass('hide');
|
|
|
|
|
$('.unmuteButton', videoControls).removeClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (requiresNativeControls) {
|
|
|
|
|
videoControls.addClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
videoControls.removeClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 16:12:09 -07:00
|
|
|
|
var video = $("video", videoElement);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
initialVolume = self.getSavedVolume();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2014-04-08 16:12:09 -07:00
|
|
|
|
video.each(function () {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
this.volume = initialVolume;
|
|
|
|
|
});
|
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
volumeSlider.val(initialVolume).slider('refresh');
|
|
|
|
|
updateVolumeButtons(initialVolume);
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
2015-05-13 20:24:25 -07:00
|
|
|
|
video.one("loadedmetadata.mediaplayerevent", function (e) {
|
|
|
|
|
|
|
|
|
|
// The IE video player won't autoplay without this
|
|
|
|
|
if ($.browser.msie) {
|
|
|
|
|
this.play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).one("playing.mediaplayerevent", function (e) {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2014-10-07 18:37:45 -07:00
|
|
|
|
// TODO: This is not working in chrome. Is it too early?
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
// Appending #t=xxx to the query string doesn't seem to work with HLS
|
|
|
|
|
if (startPositionInSeekParam && this.currentSrc && this.currentSrc.toLowerCase().indexOf('.m3u8') != -1) {
|
2015-04-20 11:35:33 -07:00
|
|
|
|
var element = this;
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
element.currentTime = startPositionInSeekParam;
|
|
|
|
|
}, 3000);
|
2014-07-16 20:17:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).on("volumechange.mediaplayerevent", function (e) {
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
var vol = this.volume;
|
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
updateVolumeButtons(vol);
|
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
|
|
|
|
|
$(this).on("ended.playbackstopped", self.onPlaybackStopped).one('ended.playnext', self.playNextAfterEnded);
|
|
|
|
|
|
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
|
|
|
|
|
2014-04-11 08:36:25 -07:00
|
|
|
|
if (!isPositionSliderActive) {
|
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-01 14:13:32 -07:00
|
|
|
|
self.stop();
|
2014-03-08 01:09:45 -07:00
|
|
|
|
|
|
|
|
|
var errorCode = this.error ? this.error.code : '';
|
2014-03-20 01:34:54 -07:00
|
|
|
|
console.log('Html5 Video error code: ' + errorCode);
|
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-08-14 06:24:30 -07:00
|
|
|
|
if ($.browser.msie && !$.browser.mobile && !self.canPlayWebm()) {
|
2014-07-21 18:29:06 -07:00
|
|
|
|
errorMsg += '<p>';
|
|
|
|
|
errorMsg += '<a href="https://tools.google.com/dlpage/webmmf/" target="_blank">';
|
|
|
|
|
errorMsg += Globalize.translate('MessageInternetExplorerWebm');
|
|
|
|
|
errorMsg += '</a>';
|
|
|
|
|
errorMsg += '</p>';
|
2014-07-01 14:13:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
|
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) {
|
|
|
|
|
if (this.paused) {
|
|
|
|
|
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
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
bindEventsForPlayback();
|
2014-03-20 01:34:54 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
mediaPlayerContainer.trigger("create");
|
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
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
$('body').addClass('bodyWithPopupOpen');
|
|
|
|
|
|
2015-04-28 06:56:57 -07:00
|
|
|
|
self.currentMediaElement = video[0];
|
|
|
|
|
self.currentDurationTicks = self.currentMediaSource.RunTimeTicks;
|
|
|
|
|
|
|
|
|
|
self.updateNowPlayingInfo(item);
|
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;
|
|
|
|
|
var requiresNativeControls = !self.enableCustomVideoControls();
|
|
|
|
|
var controls = $(requiresNativeControls ? '.videoAdvancedControls' : '.videoControls');
|
2015-03-23 10:19:21 -07:00
|
|
|
|
|
2015-03-13 01:58:50 -07:00
|
|
|
|
if (length < 2) {
|
|
|
|
|
$('.videoTrackControl').hide();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (index === 0) {
|
2015-03-13 23:24:42 -07:00
|
|
|
|
$('.previousTrackButton', controls).attr('disabled', 'disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
} else {
|
2015-03-13 23:24:42 -07:00
|
|
|
|
$('.previousTrackButton', controls).removeAttr('disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((index + 1) >= length) {
|
2015-03-13 23:24:42 -07:00
|
|
|
|
$('.nextTrackButton', controls).attr('disabled', 'disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
} else {
|
2015-03-13 23:24:42 -07:00
|
|
|
|
$('.nextTrackButton', controls).removeAttr('disabled');
|
2015-03-13 01:58:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 23:24:42 -07:00
|
|
|
|
$('.videoTrackControl', controls).show();
|
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
|
|
|
|
})();
|