2014-04-27 15:51:07 -07:00
|
|
|
|
(function (window, document, $, setTimeout, clearTimeout) {
|
|
|
|
|
|
|
|
|
|
var currentPlayer;
|
2014-04-28 08:05:28 -07:00
|
|
|
|
var lastPlayerState;
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
function populateChapters(elem, chapters, itemId, runtimeTicks) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = chapters.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var chapter = chapters[i];
|
|
|
|
|
|
|
|
|
|
html += '<div data-positionticks="' + chapter.StartPositionTicks + '" class="posterItem backdropPosterItem chapterPosterItem">';
|
|
|
|
|
|
|
|
|
|
var imgUrl;
|
|
|
|
|
|
|
|
|
|
if (chapter.ImageTag) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(itemId, {
|
|
|
|
|
width: 240,
|
2014-05-12 11:04:25 -07:00
|
|
|
|
tag: chapter.ImageTag,
|
|
|
|
|
type: "Chapter",
|
|
|
|
|
index: i
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
imgUrl = "css/images/items/list/chapter.png";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dataSrc = ' data-src="' + imgUrl + '"';
|
2015-03-06 20:53:31 -07:00
|
|
|
|
// TODO: This markup needs to be converted to the newer card layout pattern
|
2014-05-12 11:04:25 -07:00
|
|
|
|
html += '<div class="posterItemImage lazy"' + dataSrc + '>';
|
|
|
|
|
|
2015-03-06 20:53:31 -07:00
|
|
|
|
html += '<div class="posterItemTextOverlay" style="position:absolute;bottom:0;left:0;right:0;">';
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
if (chapter.Name) {
|
|
|
|
|
html += "<div class='posterItemText'>";
|
|
|
|
|
html += chapter.Name;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += "<div class='posterItemProgress posterItemText'>";
|
|
|
|
|
var pct = 100 * (chapter.StartPositionTicks / runtimeTicks);
|
2015-03-06 20:53:31 -07:00
|
|
|
|
html += '<progress class="itemProgressBar" min="0" max="100" value="' + pct + '" style="opacity:.8;width:100%;"></progress>';
|
2014-05-12 11:04:25 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
$(elem).trigger('create');
|
2014-05-12 11:04:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectCurrentChapter(elem, positionTicks) {
|
|
|
|
|
|
|
|
|
|
var elems = $('.chapterPosterItem', elem).removeClass('currentChapter');
|
|
|
|
|
|
|
|
|
|
var matches = elems.get().filter(function (i) {
|
|
|
|
|
|
|
|
|
|
var ticks = i.getAttribute('data-positionticks');
|
|
|
|
|
|
|
|
|
|
return positionTicks >= ticks;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var chapterElem = matches[matches.length - 1];
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
chapterElem.classList.add('currentChapter');
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
chapterElem.scrollIntoView();
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
elem.scrollLeft += 50;
|
2014-05-12 11:04:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showChapterMenu(page, item, currentPositionTicks) {
|
|
|
|
|
|
|
|
|
|
$('.chapterMenuOverlay', page).show();
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
var elem = page.querySelector('.chapterMenu');
|
|
|
|
|
$(elem).show();
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
if (item.Id == elem.getAttribute('data-itemid')) {
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
selectCurrentChapter(elem, currentPositionTicks);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
var innerElem = elem.querySelector('.chapterMenuInner');
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
populateChapters(innerElem, item.Chapters, item.Id, item.RunTimeTicks);
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
elem.setAttribute('data-itemid', item.Id);
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
selectCurrentChapter(elem, currentPositionTicks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideChapterMenu(page) {
|
|
|
|
|
|
|
|
|
|
$('.chapterMenuOverlay', page).hide();
|
|
|
|
|
$('.chapterMenu', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
function showAudioMenu(page, button, item, currentIndex) {
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
|
|
|
|
var streams = (item.MediaStreams || []).filter(function (i) {
|
|
|
|
|
|
|
|
|
|
return i.Type == 'Audio';
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
var menuItems = streams.map(function (s) {
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
var name = (s.Codec || '').toUpperCase();
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
|
|
|
|
if (s.Profile) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' ' + s.Profile;
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s.Language) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' · ' + s.Language;
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
if (s.Layout) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' · ' + s.Layout;
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
else if (s.Channels) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' · ' + s.Channels + ' ch';
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
var menuItem = {
|
|
|
|
|
name: name,
|
|
|
|
|
id: s.Index
|
|
|
|
|
};
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
if (s.Index == currentIndex) {
|
|
|
|
|
menuItem.ironIcon = 'check';
|
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
return menuItem;
|
|
|
|
|
});
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
require(['actionsheet'], function () {
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: button,
|
|
|
|
|
callback: function (id) {
|
2014-05-08 21:38:12 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
currentPlayer.setAudioStreamIndex(parseInt(id));
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
});
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
function showSubtitleMenu(page, button, item, currentIndex) {
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
var streams = (item.MediaStreams || []).filter(function (i) {
|
|
|
|
|
|
|
|
|
|
return i.Type == 'Subtitle';
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
var menuItems = streams.map(function (s) {
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
var name = (s.Language || Globalize.translate('LabelUnknownLanguage'));
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
|
|
|
|
if (s.IsDefault && s.IsForced) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' · ' + Globalize.translate('LabelDefaultForcedStream');
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
else if (s.IsDefault) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' · ' + Globalize.translate('LabelDefaultStream');
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
else if (s.IsForced) {
|
2015-06-26 11:32:21 -07:00
|
|
|
|
name += ' · ' + Globalize.translate('LabelForcedStream');
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
if (s.Codec) {
|
|
|
|
|
name += ' · ' + s.Codec.toUpperCase();
|
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
var menuItem = {
|
|
|
|
|
name: name,
|
|
|
|
|
id: s.Index
|
|
|
|
|
};
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
if (s.Index == currentIndex) {
|
|
|
|
|
menuItem.ironIcon = 'check';
|
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
return menuItem;
|
|
|
|
|
});
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
require(['actionsheet'], function () {
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: button,
|
|
|
|
|
callback: function (id) {
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
currentPlayer.setSubtitleStreamIndex(parseInt(id));
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-26 11:32:21 -07:00
|
|
|
|
});
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-26 14:02:23 -07:00
|
|
|
|
function toggleRepeat(player) {
|
|
|
|
|
|
|
|
|
|
if (player && lastPlayerState) {
|
|
|
|
|
var state = lastPlayerState;
|
|
|
|
|
switch ((state.PlayState || {}).RepeatMode) {
|
|
|
|
|
case 'RepeatNone':
|
|
|
|
|
player.setRepeatMode('RepeatAll');
|
|
|
|
|
break;
|
|
|
|
|
case 'RepeatAll':
|
|
|
|
|
player.setRepeatMode('RepeatOne');
|
|
|
|
|
break;
|
|
|
|
|
case 'RepeatOne':
|
|
|
|
|
player.setRepeatMode('RepeatNone');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-27 15:51:07 -07:00
|
|
|
|
function bindEvents(page) {
|
|
|
|
|
|
2014-05-08 13:09:53 -07:00
|
|
|
|
$('.tabButton', page).on('click', function () {
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
2014-05-08 13:09:53 -07:00
|
|
|
|
var elem = $('.' + this.getAttribute('data-tab'), page);
|
2014-04-27 15:51:07 -07:00
|
|
|
|
elem.siblings('.tabContent').hide();
|
|
|
|
|
|
|
|
|
|
elem.show();
|
2014-05-08 13:09:53 -07:00
|
|
|
|
|
|
|
|
|
$('.tabButton', page).removeClass('ui-btn-active');
|
|
|
|
|
$(this).addClass('ui-btn-active');
|
2014-04-27 15:51:07 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
$('.chapterMenuOverlay', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
hideChapterMenu(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.chapterMenu', page).on('click', '.chapterPosterItem', function () {
|
|
|
|
|
|
|
|
|
|
if (currentPlayer) {
|
2015-03-04 13:37:35 -07:00
|
|
|
|
var ticks = this.getAttribute('data-positionticks') || '0';
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
currentPlayer.seek(parseInt(ticks));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hideChapterMenu(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-04-28 08:05:28 -07:00
|
|
|
|
$('.btnCommand,.btnToggleFullscreen', page).on('click', function () {
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
|
2015-07-26 14:02:23 -07:00
|
|
|
|
if (this.classList.contains('repeatToggleButton')) {
|
|
|
|
|
toggleRepeat(currentPlayer);
|
|
|
|
|
} else {
|
|
|
|
|
MediaController.sendCommand({
|
|
|
|
|
Name: this.getAttribute('data-command')
|
|
|
|
|
|
|
|
|
|
}, currentPlayer);
|
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnAudioTracks', page).on('click', function () {
|
|
|
|
|
|
2014-05-10 10:28:03 -07:00
|
|
|
|
if (currentPlayer && lastPlayerState && lastPlayerState.PlayState) {
|
|
|
|
|
|
|
|
|
|
var currentIndex = lastPlayerState.PlayState.AudioStreamIndex;
|
2015-06-26 11:32:21 -07:00
|
|
|
|
showAudioMenu(page, this, lastPlayerState.NowPlayingItem, currentIndex);
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnSubtitles', page).on('click', function () {
|
|
|
|
|
|
2014-05-10 10:28:03 -07:00
|
|
|
|
if (currentPlayer && lastPlayerState && lastPlayerState.PlayState) {
|
|
|
|
|
|
|
|
|
|
var currentIndex = lastPlayerState.PlayState.SubtitleStreamIndex;
|
2015-06-26 11:32:21 -07:00
|
|
|
|
showSubtitleMenu(page, this, lastPlayerState.NowPlayingItem, currentIndex);
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnChapters', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
if (currentPlayer && lastPlayerState) {
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
var currentPositionTicks = lastPlayerState.PlayState.PositionTicks;
|
|
|
|
|
showChapterMenu(page, lastPlayerState.NowPlayingItem, currentPositionTicks);
|
2014-05-07 22:04:39 -07:00
|
|
|
|
}
|
2014-04-27 15:51:07 -07:00
|
|
|
|
});
|
2014-04-28 08:05:28 -07:00
|
|
|
|
|
|
|
|
|
$('.btnStop', page).on('click', function () {
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
currentPlayer.stop();
|
|
|
|
|
}
|
2014-04-28 08:05:28 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPlay', page).on('click', function () {
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
currentPlayer.unpause();
|
|
|
|
|
}
|
2014-04-28 08:05:28 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPause', page).on('click', function () {
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
currentPlayer.pause();
|
|
|
|
|
}
|
2014-04-28 08:05:28 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnNextTrack', page).on('click', function () {
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
currentPlayer.nextTrack();
|
|
|
|
|
}
|
2014-04-28 08:05:28 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousTrack', page).on('click', function () {
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
currentPlayer.previousTrack();
|
|
|
|
|
}
|
2014-04-28 08:05:28 -07:00
|
|
|
|
});
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
$('.nowPlayingPositionSlider', page).on('change', function () {
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
var value = this.value;
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
|
|
|
|
if (currentPlayer && lastPlayerState) {
|
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
var newPercent = parseFloat(value);
|
2014-04-30 08:07:02 -07:00
|
|
|
|
var newPositionTicks = (newPercent / 100) * lastPlayerState.NowPlayingItem.RunTimeTicks;
|
|
|
|
|
currentPlayer.seek(Math.floor(newPositionTicks));
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-03-17 21:09:31 -07:00
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
$('.nowPlayingPositionSlider', page)[0]._setPinValue = function (value) {
|
2015-03-17 21:09:31 -07:00
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
var state = lastPlayerState;
|
|
|
|
|
|
|
|
|
|
if (!state || !state.NowPlayingItem || !state.NowPlayingItem.RunTimeTicks) {
|
|
|
|
|
this.pinValue = '--:--';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ticks = state.NowPlayingItem.RunTimeTicks;
|
|
|
|
|
ticks /= 100;
|
|
|
|
|
ticks *= value;
|
|
|
|
|
|
|
|
|
|
this.pinValue = Dashboard.getDisplayTime(ticks);
|
|
|
|
|
};
|
2015-03-18 09:56:14 -07:00
|
|
|
|
|
|
|
|
|
$(page).on('click', '.lnkPlayFromIndex', function () {
|
|
|
|
|
|
|
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
|
|
|
|
|
|
|
|
|
MediaController.currentPlaylistIndex(index);
|
|
|
|
|
loadPlaylist(page);
|
|
|
|
|
|
|
|
|
|
}).on('click', '.lnkRemoveFromPlaylist', function () {
|
|
|
|
|
|
|
|
|
|
var index = parseInt(this.getAttribute('data-index'));
|
|
|
|
|
|
|
|
|
|
MediaController.removeFromPlaylist(index);
|
|
|
|
|
loadPlaylist(page);
|
|
|
|
|
});
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
Events.on(page, 'click', '.mediaItem', onListItemClick);
|
2014-04-27 15:51:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPlaybackStart(e, state) {
|
|
|
|
|
|
|
|
|
|
var player = this;
|
|
|
|
|
|
|
|
|
|
player.beginPlayerUpdates();
|
|
|
|
|
|
|
|
|
|
onStateChanged.call(player, e, state);
|
2015-07-05 11:34:52 -07:00
|
|
|
|
loadPlaylist($($.mobile.activePage)[0]);
|
2014-04-27 15:51:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPlaybackStopped(e, state) {
|
|
|
|
|
|
|
|
|
|
var player = this;
|
|
|
|
|
|
|
|
|
|
player.endPlayerUpdates();
|
2014-04-28 08:05:28 -07:00
|
|
|
|
|
2014-04-30 20:24:55 -07:00
|
|
|
|
onStateChanged.call(player, e, {});
|
2015-07-05 11:34:52 -07:00
|
|
|
|
loadPlaylist($($.mobile.activePage)[0]);
|
2014-04-27 15:51:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 17:20:01 -07:00
|
|
|
|
var lastUpdateTime = 0;
|
|
|
|
|
|
2014-04-27 15:51:07 -07:00
|
|
|
|
function onStateChanged(e, state) {
|
|
|
|
|
|
2015-07-08 17:20:01 -07:00
|
|
|
|
if (e.type == 'positionchange') {
|
|
|
|
|
// Try to avoid hammering the document with changes
|
|
|
|
|
var now = new Date().getTime();
|
|
|
|
|
if ((now - lastUpdateTime) < 700) {
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
lastUpdateTime = now;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
updatePlayerState($($.mobile.activePage)[0], state);
|
2014-04-28 08:05:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showButton(button) {
|
|
|
|
|
button.removeClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideButton(button) {
|
|
|
|
|
button.addClass('hide');
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
function hasStreams(item, type) {
|
|
|
|
|
return item && item.MediaStreams && item.MediaStreams.filter(function (i) {
|
|
|
|
|
return i.Type == type;
|
|
|
|
|
}).length > 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-28 08:05:28 -07:00
|
|
|
|
function updatePlayerState(page, state) {
|
|
|
|
|
|
|
|
|
|
lastPlayerState = state;
|
|
|
|
|
|
|
|
|
|
var item = state.NowPlayingItem;
|
|
|
|
|
|
|
|
|
|
var playerInfo = MediaController.getPlayerInfo();
|
|
|
|
|
|
|
|
|
|
var supportedCommands = playerInfo.supportedCommands;
|
2014-06-15 16:30:04 -07:00
|
|
|
|
var playState = state.PlayState || {};
|
2014-04-28 08:05:28 -07:00
|
|
|
|
|
|
|
|
|
$('.btnToggleFullscreen', page).buttonEnabled(item && item.MediaType == 'Video' && supportedCommands.indexOf('ToggleFullscreen') != -1);
|
|
|
|
|
|
2014-05-07 22:04:39 -07:00
|
|
|
|
$('.btnAudioTracks', page).buttonEnabled(hasStreams(item, 'Audio') && supportedCommands.indexOf('SetAudioStreamIndex') != -1);
|
|
|
|
|
$('.btnSubtitles', page).buttonEnabled(hasStreams(item, 'Subtitle') && supportedCommands.indexOf('SetSubtitleStreamIndex') != -1);
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
2014-06-05 17:39:02 -07:00
|
|
|
|
if (item && item.Chapters && item.Chapters.length && playState.CanSeek) {
|
2014-05-12 11:04:25 -07:00
|
|
|
|
$('.btnChapters', page).buttonEnabled(true);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$('.btnChapters', page).buttonEnabled(false);
|
|
|
|
|
hideChapterMenu(page);
|
|
|
|
|
}
|
2014-04-28 08:05:28 -07:00
|
|
|
|
|
2014-05-08 21:38:12 -07:00
|
|
|
|
$('.sendMessageElement', page).buttonEnabled(supportedCommands.indexOf('DisplayMessage') != -1);
|
2014-05-09 12:43:06 -07:00
|
|
|
|
$('.typeTextElement', page).buttonEnabled(supportedCommands.indexOf('SendString') != -1);
|
2014-05-08 21:38:12 -07:00
|
|
|
|
|
2014-04-28 08:05:28 -07:00
|
|
|
|
$('.btnStop', page).buttonEnabled(item != null);
|
|
|
|
|
$('.btnNextTrack', page).buttonEnabled(item != null);
|
|
|
|
|
$('.btnPreviousTrack', page).buttonEnabled(item != null);
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2014-04-28 08:05:28 -07:00
|
|
|
|
var btnPause = $('.btnPause', page).buttonEnabled(item != null);
|
|
|
|
|
var btnPlay = $('.btnPlay', page).buttonEnabled(item != null);
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2014-04-28 08:05:28 -07:00
|
|
|
|
if (playState.IsPaused) {
|
|
|
|
|
|
|
|
|
|
hideButton(btnPause);
|
|
|
|
|
showButton(btnPlay);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
showButton(btnPause);
|
|
|
|
|
hideButton(btnPlay);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
var positionSlider = $('.nowPlayingPositionSlider', page)[0];
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
if (!positionSlider.dragging) {
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
|
|
|
|
if (item && item.RunTimeTicks) {
|
|
|
|
|
|
|
|
|
|
var pct = playState.PositionTicks / item.RunTimeTicks;
|
|
|
|
|
pct *= 100;
|
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
positionSlider.value = pct;
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
positionSlider.value = 0;
|
2014-04-30 08:07:02 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
positionSlider.disabled = !playState.CanSeek;
|
2014-04-30 08:07:02 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (playState.PositionTicks == null) {
|
|
|
|
|
$('.positionTime', page).html('--:--');
|
|
|
|
|
} else {
|
|
|
|
|
$('.positionTime', page).html(Dashboard.getDisplayTime(playState.PositionTicks));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item && item.RunTimeTicks != null) {
|
|
|
|
|
$('.runtime', page).html(Dashboard.getDisplayTime(item.RunTimeTicks));
|
|
|
|
|
} else {
|
|
|
|
|
$('.runtime', page).html('--:--');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item && item.MediaType == 'Video') {
|
|
|
|
|
$('.videoButton', page).css('visibility', 'visible');
|
|
|
|
|
} else {
|
|
|
|
|
$('.videoButton', page).css('visibility', 'hidden');
|
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2015-06-29 18:56:25 -07:00
|
|
|
|
if (playerInfo.isLocalPlayer && AppInfo.hasPhysicalVolumeButtons) {
|
|
|
|
|
$('.volumeButton', page).css('visibility', 'hidden');
|
|
|
|
|
} else {
|
|
|
|
|
$('.volumeButton', page).css('visibility', 'visible');
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-26 14:02:23 -07:00
|
|
|
|
if (item && item.MediaType == 'Audio') {
|
2015-06-29 18:56:25 -07:00
|
|
|
|
$('.buttonsRow2', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('.buttonsRow2', page).show();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-26 14:02:23 -07:00
|
|
|
|
var toggleRepeatButton = page.querySelector('.repeatToggleButton');
|
|
|
|
|
|
|
|
|
|
if (playState.RepeatMode == 'RepeatAll') {
|
|
|
|
|
toggleRepeatButton.icon = "repeat";
|
|
|
|
|
toggleRepeatButton.classList.add('nowPlayingPageRepeatActive');
|
|
|
|
|
}
|
|
|
|
|
else if (playState.RepeatMode == 'RepeatOne') {
|
|
|
|
|
toggleRepeatButton.icon = "repeat-one";
|
|
|
|
|
toggleRepeatButton.classList.add('nowPlayingPageRepeatActive');
|
|
|
|
|
} else {
|
|
|
|
|
toggleRepeatButton.icon = "repeat";
|
|
|
|
|
toggleRepeatButton.classList.remove('nowPlayingPageRepeatActive');
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-30 08:07:02 -07:00
|
|
|
|
updateNowPlayingInfo(page, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentImgUrl;
|
|
|
|
|
function updateNowPlayingInfo(page, state) {
|
|
|
|
|
|
|
|
|
|
var item = state.NowPlayingItem;
|
2015-06-26 20:27:38 -07:00
|
|
|
|
var displayName = item ? MediaController.getNowPlayingNameHtml(item).replace('<br/>', ' - ') : '';
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
2015-06-26 20:27:38 -07:00
|
|
|
|
$('.nowPlayingPageTitle', page).html(displayName).visible(displayName.length > 0);
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
|
|
|
|
var url;
|
2015-05-09 21:29:04 -07:00
|
|
|
|
var backdropUrl = null;
|
2014-04-30 08:07:02 -07:00
|
|
|
|
|
|
|
|
|
if (!item) {
|
|
|
|
|
}
|
|
|
|
|
else if (item.PrimaryImageTag) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.PrimaryImageItemId, {
|
2014-04-30 08:07:02 -07:00
|
|
|
|
type: "Primary",
|
2014-05-23 16:58:28 -07:00
|
|
|
|
height: 300,
|
2014-04-30 08:07:02 -07:00
|
|
|
|
tag: item.PrimaryImageTag
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (item.BackdropImageTag) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.BackdropItemId, {
|
2014-04-30 08:07:02 -07:00
|
|
|
|
type: "Backdrop",
|
2014-05-23 16:58:28 -07:00
|
|
|
|
height: 300,
|
2014-04-30 08:07:02 -07:00
|
|
|
|
tag: item.BackdropImageTag,
|
|
|
|
|
index: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else if (item.ThumbImageTag) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.ThumbImageItemId, {
|
2014-04-30 08:07:02 -07:00
|
|
|
|
type: "Thumb",
|
2014-05-23 16:58:28 -07:00
|
|
|
|
height: 300,
|
2014-04-30 08:07:02 -07:00
|
|
|
|
tag: item.ThumbImageTag
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (url == currentImgUrl) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
if (item && item.BackdropImageTag) {
|
|
|
|
|
|
|
|
|
|
backdropUrl = ApiClient.getScaledImageUrl(item.BackdropItemId, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: $(window).width(),
|
|
|
|
|
tag: item.BackdropImageTag,
|
|
|
|
|
index: 0
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-30 20:24:55 -07:00
|
|
|
|
setImageUrl(page, url);
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
|
|
|
|
Backdrops.setBackdropUrl(page, backdropUrl);
|
2015-06-28 09:36:25 -07:00
|
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), item.Id).done(function (fullItem) {
|
|
|
|
|
page.querySelector('.nowPlayingPageUserDataButtons').innerHTML = LibraryBrowser.getUserDataIconsHtml(fullItem, false);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
page.querySelector('.nowPlayingPageUserDataButtons').innerHTML = '';
|
|
|
|
|
}
|
2014-04-30 20:24:55 -07:00
|
|
|
|
}
|
2014-05-07 22:04:39 -07:00
|
|
|
|
|
2014-04-30 20:24:55 -07:00
|
|
|
|
function setImageUrl(page, url) {
|
2014-04-30 08:07:02 -07:00
|
|
|
|
currentImgUrl = url;
|
|
|
|
|
|
|
|
|
|
$('.nowPlayingPageImage', page).html(url ? '<img src="' + url + '" />' : '');
|
2014-04-27 15:51:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateSupportedCommands(page, commands) {
|
|
|
|
|
|
|
|
|
|
$('.btnCommand', page).each(function () {
|
|
|
|
|
|
|
|
|
|
$(this).buttonEnabled(commands.indexOf(this.getAttribute('data-command')) != -1);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function releaseCurrentPlayer() {
|
|
|
|
|
|
|
|
|
|
if (currentPlayer) {
|
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(currentPlayer).off('playbackstart', onPlaybackStart)
|
|
|
|
|
.off('playbackstop', onPlaybackStopped)
|
|
|
|
|
.off('volumechange', onStateChanged)
|
|
|
|
|
.off('playstatechange', onStateChanged)
|
|
|
|
|
.off('positionchange', onStateChanged);
|
|
|
|
|
|
2014-04-27 15:51:07 -07:00
|
|
|
|
currentPlayer.endPlayerUpdates();
|
|
|
|
|
currentPlayer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindToPlayer(page, player) {
|
|
|
|
|
|
|
|
|
|
releaseCurrentPlayer();
|
|
|
|
|
|
|
|
|
|
currentPlayer = player;
|
|
|
|
|
|
|
|
|
|
player.getPlayerState().done(function (state) {
|
|
|
|
|
|
2014-04-28 20:56:20 -07:00
|
|
|
|
if (state.NowPlayingItem) {
|
2014-04-27 15:51:07 -07:00
|
|
|
|
player.beginPlayerUpdates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onStateChanged.call(player, { type: 'init' }, state);
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(player).on('playbackstart', onPlaybackStart)
|
|
|
|
|
.on('playbackstop', onPlaybackStopped)
|
|
|
|
|
.on('volumechange', onStateChanged)
|
|
|
|
|
.on('playstatechange', onStateChanged)
|
|
|
|
|
.on('positionchange', onStateChanged);
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
|
|
|
|
var playerInfo = MediaController.getPlayerInfo();
|
|
|
|
|
|
|
|
|
|
var supportedCommands = playerInfo.supportedCommands;
|
|
|
|
|
|
|
|
|
|
updateSupportedCommands(page, supportedCommands);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-18 09:56:14 -07:00
|
|
|
|
function loadPlaylist(page) {
|
|
|
|
|
|
2015-04-30 20:00:29 -07:00
|
|
|
|
var html = '';
|
2015-03-18 09:56:14 -07:00
|
|
|
|
|
2015-05-10 06:06:12 -07:00
|
|
|
|
//ApiClient.getItems(Dashboard.getCurrentUserId(), {
|
|
|
|
|
|
|
|
|
|
// SortBy: "SortName",
|
|
|
|
|
// SortOrder: "Ascending",
|
|
|
|
|
// IncludeItemTypes: "Audio",
|
|
|
|
|
// Recursive: true,
|
|
|
|
|
// Fields: "PrimaryImageAspectRatio,SortName,MediaSourceCount,IsUnidentified,SyncInfo",
|
|
|
|
|
// StartIndex: 0,
|
|
|
|
|
// ImageTypeLimit: 1,
|
|
|
|
|
// EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
|
|
|
|
// Limit: 100
|
|
|
|
|
|
|
|
|
|
//}).done(function (result) {
|
|
|
|
|
|
|
|
|
|
// html += LibraryBrowser.getListViewHtml({
|
|
|
|
|
// items: result.Items,
|
|
|
|
|
// smallIcon: true
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// $(".playlist", page).html(html).trigger('create').lazyChildren();
|
|
|
|
|
//});
|
2015-04-30 20:00:29 -07:00
|
|
|
|
|
2015-05-10 06:06:12 -07:00
|
|
|
|
html += LibraryBrowser.getListViewHtml({
|
|
|
|
|
items: MediaController.playlist(),
|
|
|
|
|
smallIcon: true
|
2015-03-18 09:56:14 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-28 09:36:25 -07:00
|
|
|
|
var itemsContainer = page.querySelector('.playlist');
|
2015-06-28 08:43:49 -07:00
|
|
|
|
itemsContainer.innerHTML = html;
|
2015-06-28 09:36:25 -07:00
|
|
|
|
ImageLoader.lazyChildren(itemsContainer);
|
|
|
|
|
$(itemsContainer).trigger('create');
|
2015-03-18 09:56:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
function onListItemClick(e) {
|
|
|
|
|
|
|
|
|
|
var info = LibraryBrowser.getListItemInfo(this);
|
|
|
|
|
|
|
|
|
|
MediaController.currentPlaylistIndex(info.index);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 08:53:49 -07:00
|
|
|
|
function updateCastIcon() {
|
|
|
|
|
|
|
|
|
|
var info = MediaController.getPlayerInfo();
|
|
|
|
|
|
|
|
|
|
if (info.isLocalPlayer) {
|
|
|
|
|
|
|
|
|
|
$('.nowPlayingCastIcon').each(function () {
|
|
|
|
|
this.icon = 'cast';
|
|
|
|
|
});
|
2015-07-14 09:39:34 -07:00
|
|
|
|
$('.nowPlayingSelectedPlayer').html('');
|
2015-06-26 08:53:49 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$('.nowPlayingCastIcon').each(function () {
|
|
|
|
|
this.icon = 'cast-connected';
|
|
|
|
|
});
|
|
|
|
|
|
2015-07-14 09:39:34 -07:00
|
|
|
|
$('.nowPlayingSelectedPlayer').html((info.deviceName || info.name));
|
2015-06-26 08:53:49 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function onPlayerChange() {
|
|
|
|
|
bindToPlayer($($.mobile.activePage)[0], MediaController.getCurrentPlayer());
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 22:00:56 -07:00
|
|
|
|
function showSlideshowMenu(page) {
|
|
|
|
|
require(['scripts/slideshow'], function () {
|
|
|
|
|
SlideShow.showMenu();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 22:56:46 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#nowPlayingPage", function () {
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
bindEvents(page);
|
|
|
|
|
|
2015-06-08 22:56:46 -07:00
|
|
|
|
$('.sendMessageForm').off('submit', NowPlayingPage.onMessageSubmit).on('submit', NowPlayingPage.onMessageSubmit);
|
|
|
|
|
$('.typeTextForm').off('submit', NowPlayingPage.onSendStringSubmit).on('submit', NowPlayingPage.onSendStringSubmit);
|
|
|
|
|
|
2015-06-26 13:40:30 -07:00
|
|
|
|
$('.requiresJqmCreate', this).trigger('create');
|
2015-06-26 08:53:49 -07:00
|
|
|
|
|
2015-08-20 22:00:56 -07:00
|
|
|
|
$('.btnSlideshow').on('click', function () {
|
|
|
|
|
showSlideshowMenu(page);
|
|
|
|
|
});
|
|
|
|
|
|
2015-08-01 14:17:46 -07:00
|
|
|
|
var tabs = page.querySelector('paper-tabs');
|
2015-07-01 22:08:05 -07:00
|
|
|
|
tabs.alignBottom = true;
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.configureSwipeTabs(page, tabs, page.querySelectorAll('neon-animated-pages')[0]);
|
2015-06-26 08:53:49 -07:00
|
|
|
|
|
2015-08-20 22:00:56 -07:00
|
|
|
|
$(tabs).on('iron-select', function () {
|
|
|
|
|
page.querySelector('neon-animated-pages').selected = this.selected;
|
2015-06-26 08:53:49 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-08-20 22:00:56 -07:00
|
|
|
|
$(MediaController).on('playerchange', function () {
|
|
|
|
|
updateCastIcon(page);
|
2015-06-26 13:40:30 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-18 21:23:55 -07:00
|
|
|
|
}).on('pagebeforeshowready', "#nowPlayingPage", function () {
|
2014-04-28 20:56:20 -07:00
|
|
|
|
|
2015-06-27 16:18:09 -07:00
|
|
|
|
$(document.body).addClass('hiddenViewMenuBar').addClass('hiddenNowPlayingBar');
|
2014-04-28 20:56:20 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
currentImgUrl = null;
|
|
|
|
|
|
2015-06-30 16:59:45 -07:00
|
|
|
|
$(MediaController).on('playerchange', onPlayerChange);
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
2015-06-30 16:59:45 -07:00
|
|
|
|
bindToPlayer(page, MediaController.getCurrentPlayer());
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
2015-03-18 09:56:14 -07:00
|
|
|
|
loadPlaylist(page);
|
2015-03-17 21:09:31 -07:00
|
|
|
|
|
2015-07-03 04:51:45 -07:00
|
|
|
|
var tab = window.location.hash;
|
|
|
|
|
var selected = tab == '#playlist' ? 2 : 0;;
|
2015-06-26 13:40:30 -07:00
|
|
|
|
this.querySelectorAll('paper-tabs')[0].selected = selected;
|
2015-06-26 08:53:49 -07:00
|
|
|
|
|
|
|
|
|
updateCastIcon(page);
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', "#nowPlayingPage", function () {
|
2014-04-27 15:51:07 -07:00
|
|
|
|
|
|
|
|
|
releaseCurrentPlayer();
|
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$(MediaController).off('playerchange', onPlayerChange);
|
2014-04-28 08:05:28 -07:00
|
|
|
|
|
|
|
|
|
lastPlayerState = null;
|
2015-06-27 16:18:09 -07:00
|
|
|
|
$(document.body).removeClass('hiddenViewMenuBar').removeClass('hiddenNowPlayingBar');
|
2014-04-27 15:51:07 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-05-08 21:38:12 -07:00
|
|
|
|
window.NowPlayingPage = {
|
|
|
|
|
|
|
|
|
|
onMessageSubmit: function () {
|
|
|
|
|
|
|
|
|
|
var form = this;
|
|
|
|
|
|
|
|
|
|
MediaController.sendCommand({
|
|
|
|
|
Name: 'DisplayMessage',
|
|
|
|
|
Arguments: {
|
|
|
|
|
|
|
|
|
|
Header: $('#txtMessageTitle', form).val(),
|
|
|
|
|
Text: $('#txtMessageText', form).val()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, currentPlayer);
|
|
|
|
|
|
|
|
|
|
$('input', form).val('');
|
|
|
|
|
Dashboard.alert('Message sent.');
|
|
|
|
|
|
2014-05-09 12:43:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
},
|
2014-05-12 11:04:25 -07:00
|
|
|
|
|
|
|
|
|
onSendStringSubmit: function () {
|
|
|
|
|
|
2014-05-09 12:43:06 -07:00
|
|
|
|
var form = this;
|
|
|
|
|
|
|
|
|
|
MediaController.sendCommand({
|
|
|
|
|
Name: 'SendString',
|
|
|
|
|
Arguments: {
|
|
|
|
|
|
|
|
|
|
String: $('#txtTypeText', form).val()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, currentPlayer);
|
|
|
|
|
|
|
|
|
|
$('input', form).val('');
|
|
|
|
|
Dashboard.alert('Text sent.');
|
|
|
|
|
|
2014-05-08 21:38:12 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-27 15:51:07 -07:00
|
|
|
|
})(window, document, jQuery, setTimeout, clearTimeout);
|