1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

add mono CreateWebRequest workaround

This commit is contained in:
Luke Pulverenti 2015-06-07 17:21:30 -04:00
parent 386e63ee64
commit ec469a7b05
18 changed files with 184 additions and 106 deletions

View file

@ -69,7 +69,7 @@
} }
.bottomPaddedCard .cardBox { .bottomPaddedCard .cardBox {
margin-bottom: 5px; margin-bottom: 12px;
} }
.visualCardBox { .visualCardBox {
@ -85,7 +85,7 @@
} }
.ui-page-theme-b .visualCardBox { .ui-page-theme-b .visualCardBox {
background: rgba(45,45,45,.85); background: rgba(40,40,40,.85);
border-radius: 3px; border-radius: 3px;
} }
@ -174,7 +174,7 @@
} }
.visualCardBox .outerCardFooter { .visualCardBox .outerCardFooter {
padding: 5px; padding: 3px;
position: relative; position: relative;
} }
@ -195,6 +195,12 @@
line-height: 1.4; line-height: 1.4;
} }
.cardButtonContainer {
text-align: right;
float: right;
padding: 5px 0 2px;
}
.cardContent .cardFooter .cardText { .cardContent .cardFooter .cardText {
font-size: 14px; font-size: 14px;
} }
@ -220,7 +226,6 @@
} }
.cardBox:not(.visualCardBox) .outerCardFooter .cardText:last-child { .cardBox:not(.visualCardBox) .outerCardFooter .cardText:last-child {
margin-bottom: 2em;
} }
@media all and (max-width: 600px) { @media all and (max-width: 600px) {

View file

@ -1367,13 +1367,6 @@ span.itemCommunityRating:not(:empty) + .userDataIcons {
margin: 0 auto !important; margin: 0 auto !important;
} }
.itemsListview .ui-li-aside {
right: 70px;
font-size: 13px;
top: 35%;
font-weight: 300 !important;
}
.itemsListview .ui-li-count { .itemsListview .ui-li-count {
right: 1em; right: 1em;
top: 70%; top: 70%;
@ -1409,11 +1402,20 @@ span.itemCommunityRating:not(:empty) + .userDataIcons {
background-position: center center; background-position: center center;
} }
.listViewMoreButton { .listViewAside {
position: absolute; position: absolute;
right: 0; right: 0;
top: 10%; top: 10%;
padding: 15px 20px; }
.listViewAside button {
padding: 15px 10px;
margin: 0 !important;
vertical-align: middle;
}
.listViewMoreButton {
padding-left: 20px !important;
font-size: 20px; font-size: 20px;
} }
@ -1475,9 +1477,27 @@ span.itemCommunityRating:not(:empty) + .userDataIcons {
color: #2ad; color: #2ad;
} }
.listViewUserDataButtons {
visibility: hidden;
}
@media all and (min-width: 1200px) {
li:hover .listViewUserDataButtons {
visibility: visible !important;
}
}
@media all and (max-width: 1200px) {
.listViewUserDataButtons {
display: none;
}
}
@media all and (max-width: 600px) { @media all and (max-width: 600px) {
.itemsListview .ui-li-aside { .listViewAsideText {
display: none; display: none;
} }
} }

View file

@ -38,7 +38,7 @@
update('enableItemPreviews', val.toString()); update('enableItemPreviews', val.toString());
} }
return store.getItem('enableItemPreviews') != 'false'; return store.getItem('enableItemPreviews') == 'true';
}, },
enableFullScreen: function (val) { enableFullScreen: function (val) {

View file

@ -85,7 +85,7 @@
type: "Backdrop", type: "Backdrop",
tag: item.tag, tag: item.tag,
maxWidth: screenWidth, maxWidth: screenWidth,
quality: 80 quality: 50
}); });
setBackdropImage(getElement(), imgUrl); setBackdropImage(getElement(), imgUrl);
@ -174,7 +174,7 @@
type: "Backdrop", type: "Backdrop",
tag: item.tag, tag: item.tag,
maxWidth: screenWidth, maxWidth: screenWidth,
quality: 80 quality: 50
}); });
setBackdropImage(getElement(), imgUrl); setBackdropImage(getElement(), imgUrl);

View file

@ -147,9 +147,9 @@
context: 'channels', context: 'channels',
showTitle: true, showTitle: true,
coverImage: true, coverImage: true,
cardLayout: true,
showYear: true, showYear: true,
lazy: true lazy: true,
centerText: true
}); });
var elem = $('#items', page).html(html).lazyChildren(); var elem = $('#items', page).html(html).lazyChildren();

View file

@ -32,51 +32,51 @@
var item = items[i]; var item = items[i];
var icon; var icon;
var backgroundColor = 'rgba(82, 181, 75, 0.7)'; var backgroundColor = 'rgba(82, 181, 75, 0.9)';
switch (item.CollectionType) { switch (item.CollectionType) {
case "movies": case "movies":
icon = "fa-film"; icon = "fa-film";
backgroundColor = 'rgba(176, 94, 81, 0.7)'; backgroundColor = 'rgba(176, 94, 81, 0.9)';
break; break;
case "music": case "music":
icon = "fa-music"; icon = "fa-music";
backgroundColor = 'rgba(217, 145, 67, 0.7)'; backgroundColor = 'rgba(217, 145, 67, 0.9)';
break; break;
case "photos": case "photos":
icon = "fa-photo"; icon = "fa-photo";
backgroundColor = 'rgba(127, 0, 0, 0.7)'; backgroundColor = 'rgba(127, 0, 0, 0.9)';
break; break;
case "livetv": case "livetv":
icon = "fa-video-camera"; icon = "fa-video-camera";
backgroundColor = 'rgba(255, 233, 127, 0.7)'; backgroundColor = 'rgba(217, 145, 67, 0.9)';
break; break;
case "tvshows": case "tvshows":
icon = "fa-video-camera"; icon = "fa-video-camera";
backgroundColor = 'rgba(77, 88, 164, 0.7)'; backgroundColor = 'rgba(77, 88, 164, 0.9)';
break; break;
case "games": case "games":
icon = "fa-gamepad"; icon = "fa-gamepad";
backgroundColor = 'rgba(183, 202, 72, 0.7)'; backgroundColor = 'rgba(183, 202, 72, 0.9)';
break; break;
case "trailers": case "trailers":
icon = "fa-film"; icon = "fa-film";
backgroundColor = 'rgba(176, 94, 81, 0.7)'; backgroundColor = 'rgba(176, 94, 81, 0.9)';
break; break;
case "homevideos": case "homevideos":
icon = "fa-video-camera"; icon = "fa-video-camera";
backgroundColor = 'rgba(110, 52, 32, 0.7)'; backgroundColor = 'rgba(110, 52, 32, 0.9)';
break; break;
case "musicvideos": case "musicvideos":
icon = "fa-video-camera"; icon = "fa-video-camera";
backgroundColor = 'rgba(143, 54, 168, 0.7)'; backgroundColor = 'rgba(143, 54, 168, 0.9)';
break; break;
case "books": case "books":
icon = "fa-book"; icon = "fa-book";
break; break;
case "channels": case "channels":
icon = "fa-globe"; icon = "fa-globe";
backgroundColor = 'rgba(51, 136, 204, 0.7)'; backgroundColor = 'rgba(51, 136, 204, 0.9)';
break; break;
case "playlists": case "playlists":
icon = "fa-list"; icon = "fa-list";
@ -153,7 +153,7 @@
html += '<div>'; html += '<div>';
html += '<h1 style="display:inline-block; vertical-align:middle;" class="listHeader">' + Globalize.translate('HeaderLatestMedia') + '</h1>'; html += '<h1 style="display:inline-block; vertical-align:middle;" class="listHeader">' + Globalize.translate('HeaderLatestMedia') + '</h1>';
if (user.Policy.EnableUserPreferenceAccess) { if (user.Policy.EnableUserPreferenceAccess && !AppInfo.isNativeApp) {
html += '<a href="mypreferencesdisplay.html" class="accentButton"><i class="fa fa-pencil"></i>' + Globalize.translate('ButtonEdit') + '</a>'; html += '<a href="mypreferencesdisplay.html" class="accentButton"><i class="fa fa-pencil"></i>' + Globalize.translate('ButtonEdit') + '</a>';
} }
@ -235,7 +235,7 @@
html += '<div>'; html += '<div>';
html += '<h1 style="display:inline-block; vertical-align:middle;" class="' + cssClass + '">' + Globalize.translate('HeaderMyMedia') + '</h1>'; html += '<h1 style="display:inline-block; vertical-align:middle;" class="' + cssClass + '">' + Globalize.translate('HeaderMyMedia') + '</h1>';
if (user.Policy.EnableUserPreferenceAccess) { if (user.Policy.EnableUserPreferenceAccess && !AppInfo.isNativeApp) {
html += '<a href="mypreferencesdisplay.html" class="accentButton"><i class="fa fa-pencil"></i>' + Globalize.translate('ButtonEdit') + '</a>'; html += '<a href="mypreferencesdisplay.html" class="accentButton"><i class="fa fa-pencil"></i>' + Globalize.translate('ButtonEdit') + '</a>';
} }
@ -461,7 +461,7 @@
(function ($, document) { (function ($, document) {
var defaultFirstSection = 'smalllibrarytiles-automobile'; var defaultFirstSection = 'smalllibrarytiles';
function getDefaultSection(index) { function getDefaultSection(index) {
@ -643,7 +643,10 @@
Dashboard.getCurrentUser().done(function (user) { Dashboard.getCurrentUser().done(function (user) {
loadSections(page, user, result).done(function () { loadSections(page, user, result).done(function () {
if (!AppInfo.isNativeApp) {
showWelcomeIfNeeded(page, result); showWelcomeIfNeeded(page, result);
}
}); });
}); });

View file

@ -453,7 +453,8 @@
html = LibraryBrowser.getListViewHtml({ html = LibraryBrowser.getListViewHtml({
items: result.Items, items: result.Items,
playFromHere: true, playFromHere: true,
defaultAction: 'playallfromhere' defaultAction: 'playallfromhere',
smallIcon: true
}); });
} }
else if (query.IncludeItemTypes == "Movie" || query.IncludeItemTypes == "Trailer") { else if (query.IncludeItemTypes == "Movie" || query.IncludeItemTypes == "Trailer") {
@ -503,7 +504,8 @@
else { else {
html = LibraryBrowser.getListViewHtml({ html = LibraryBrowser.getListViewHtml({
items: result.Items items: result.Items,
smallIcon: true
}); });
} }

View file

@ -125,7 +125,7 @@
Dashboard.getCurrentUser().done(function (user) { Dashboard.getCurrentUser().done(function (user) {
if (user.Policy.IsAdministrator && query.ParentId) { if (user.Policy.IsAdministrator && query.ParentId && !AppInfo.isNativeApp) {
$('#editButtonContainer', page).show(); $('#editButtonContainer', page).show();
} else { } else {
$('#editButtonContainer', page).hide(); $('#editButtonContainer', page).hide();

View file

@ -848,10 +848,6 @@
html += '</p>'; html += '</p>';
} }
html += '<div class="ui-li-aside">';
html += textlines[verticalTextLines] || LibraryBrowser.getRatingHtml(item, false);
html += '</div>';
html += LibraryBrowser.getSyncIndicator(item); html += LibraryBrowser.getSyncIndicator(item);
if (item.Type == 'Series' || item.Type == 'Season' || item.Type == 'BoxSet' || item.MediaType == 'Video') { if (item.Type == 'Series' || item.Type == 'Season' || item.Type == 'BoxSet' || item.MediaType == 'Video') {
@ -863,9 +859,17 @@
} }
html += '</a>'; html += '</a>';
html += '<div class="listViewAside">';
html += '<span class="listViewAsideText">';
html += textlines[verticalTextLines] || LibraryBrowser.getRatingHtml(item, false);
html += '</span>';
html += '<button type="button" data-role="none" class="listviewMenuButton imageButton listViewMoreButton" data-icon="none">'; html += '<button type="button" data-role="none" class="listviewMenuButton imageButton listViewMoreButton" data-icon="none">';
html += '<i class="material-icons">more_vert</i>'; html += '<i class="material-icons">more_vert</i>';
html += '</button>'; html += '</button>';
html += '<span class="listViewUserDataButtons">';
html += LibraryBrowser.getUserDataIconsHtml(item);
html += '</span>';
html += '</div>';
html += '</li>'; html += '</li>';
@ -1553,7 +1557,7 @@
html += '<div class="' + footerClass + '">'; html += '<div class="' + footerClass + '">';
if (options.cardLayout) { if (options.cardLayout) {
html += '<div class="cardText" style="text-align:right; float:right;">'; html += '<div class="cardButtonContainer">';
html += '<button class="listviewMenuButton imageButton btnCardOptions" type="button" data-role="none" style="margin: 4px 0 0;"><i class="material-icons">more_vert</i></button>'; html += '<button class="listviewMenuButton imageButton btnCardOptions" type="button" data-role="none" style="margin: 4px 0 0;"><i class="material-icons">more_vert</i></button>';
html += "</div>"; html += "</div>";
} }
@ -2269,7 +2273,7 @@
btnCssClass += " imageButton"; btnCssClass += " imageButton";
return '<button data-itemid="' + itemId + '" class="' + btnCssClass + '" type="button" onclick="LibraryBrowser.' + method + '(this);return false;" title="' + tooltip + '"><i class="fa ' + icon + '"></i></button>'; return '<button data-itemid="' + itemId + '" class="' + btnCssClass + '" type="button" onclick="LibraryBrowser.' + method + '(this);return false;" title="' + tooltip + '" data-role="none"><i class="fa ' + icon + '"></i></button>';
}, },
@ -2284,7 +2288,7 @@
var tooltipPlayed = Globalize.translate('TooltipPlayed'); var tooltipPlayed = Globalize.translate('TooltipPlayed');
if ((item.MediaType || item.IsFolder) && type != "TvChannel" && type != "MusicArtist") { if ((item.MediaType || item.IsFolder) && type != "TvChannel" && type != "MusicArtist" && item.MediaType != "Audio") {
if (userData.Played) { if (userData.Played) {
html += LibraryBrowser.getUserDataButtonHtml('markPlayed', itemId, 'btnUserItemRating btnUserItemRating', 'fa-check', tooltipPlayed); html += LibraryBrowser.getUserDataButtonHtml('markPlayed', itemId, 'btnUserItemRating btnUserItemRating', 'fa-check', tooltipPlayed);
} else { } else {

View file

@ -38,7 +38,7 @@
// html += '<button class="headerButtonViewMenu headerButton headerButtonRight" type="button" data-role="none"><i class="material-icons">more_vert</i></button>'; // html += '<button class="headerButtonViewMenu headerButton headerButtonRight" type="button" data-role="none"><i class="material-icons">more_vert</i></button>';
//} //}
if (!$.browser.mobile && !AppInfo.isTouchPreferred) { if (!$.browser.mobile && !AppInfo.isNativeApp) {
html += '<a href="dashboard.html" class="headerButton headerButtonRight dashboardEntryHeaderButton" style="display:none;"><i class="material-icons">settings</i></a>'; html += '<a href="dashboard.html" class="headerButton headerButtonRight dashboardEntryHeaderButton" style="display:none;"><i class="material-icons">settings</i></a>';
} }
@ -101,6 +101,21 @@
$(initViewMenuBarHeadroom); $(initViewMenuBarHeadroom);
//$('.headerButtonViewMenu').off('click', onViewButtonClick).on('click', onViewButtonClick); //$('.headerButtonViewMenu').off('click', onViewButtonClick).on('click', onViewButtonClick);
if (AppInfo.isNativeApp) {
$(document).off('swiperight.drawer').on('swiperight.drawer', '.libraryPage', onSwipeRight);
}
}
function onSwipeRight(event) {
if (event.swipestop && event.swipestop.coords) {
var x = event.swipestop.coords[0];
if (x < 50) {
showLibraryMenu();
}
}
} }
//function onViewButtonClick() { //function onViewButtonClick() {
@ -155,7 +170,7 @@
html += Globalize.translate('HeaderAdmin'); html += Globalize.translate('HeaderAdmin');
html += '</div>'; html += '</div>';
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="dashboard" href="dashboard.html"><span class="fa fa-server sidebarLinkIcon"></span>' + Globalize.translate('ButtonManageServer') + '</a>'; html += '<a class="sidebarLink lnkMediaFolder lnkManageServer" data-itemid="dashboard" href="#"><span class="fa fa-server sidebarLinkIcon"></span>' + Globalize.translate('ButtonManageServer') + '</a>';
html += '<a class="sidebarLink lnkMediaFolder editorViewMenu" data-itemid="editor" href="edititemmetadata.html"><span class="fa fa-edit sidebarLinkIcon"></span>' + Globalize.translate('ButtonMetadataManager') + '</a>'; html += '<a class="sidebarLink lnkMediaFolder editorViewMenu" data-itemid="editor" href="edititemmetadata.html"><span class="fa fa-edit sidebarLinkIcon"></span>' + Globalize.translate('ButtonMetadataManager') + '</a>';
if (!$.browser.mobile && !AppInfo.isTouchPreferred) { if (!$.browser.mobile && !AppInfo.isTouchPreferred) {
@ -412,6 +427,8 @@
panel = $('#libraryPanel').panel({}).lazyChildren().trigger('create'); panel = $('#libraryPanel').panel({}).lazyChildren().trigger('create');
$('.lnkManageServer', panel).on('click', onManageServerClicked);
updateLibraryMenu(); updateLibraryMenu();
} }
else if (requiresLibraryMenuRefresh) { else if (requiresLibraryMenuRefresh) {
@ -422,6 +439,17 @@
return panel; return panel;
} }
function onManageServerClicked() {
requirejs(["scripts/registrationservices"], function () {
RegistrationServices.validateFeature('manageserver').done(function () {
Dashboard.navigate('dashboard.html');
});
});
}
function getDashboardMenu(page) { function getDashboardMenu(page) {
var panel = $('#dashboardPanel', page); var panel = $('#dashboardPanel', page);

View file

@ -1109,7 +1109,10 @@
var requiresNativeControls = !self.enableCustomVideoControls(); var requiresNativeControls = !self.enableCustomVideoControls();
// Can't autoplay in these browsers so we need to use the full controls // Can't autoplay in these browsers so we need to use the full controls
if (requiresNativeControls) { if (requiresNativeControls && AppInfo.isNativeApp && $.browser.android) {
html += '<video data-viblast-key="N8FjNTQ3NDdhZqZhNGI5NWU5ZTI=" class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="anonymous" ' + posterCode + ' webkit-playsinline>';
}
else if (requiresNativeControls) {
html += '<video data-viblast-key="N8FjNTQ3NDdhZqZhNGI5NWU5ZTI=" class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="anonymous" controls="controls"' + posterCode + ' webkit-playsinline>'; html += '<video data-viblast-key="N8FjNTQ3NDdhZqZhNGI5NWU5ZTI=" class="itemVideo" id="itemVideo" preload="metadata" autoplay="autoplay" crossorigin="anonymous" controls="controls"' + posterCode + ' webkit-playsinline>';
} }
else { else {
@ -1219,6 +1222,10 @@
}, 3000); }, 3000);
} }
if (requiresNativeControls) {
$(this).attr('controls', 'controls');
}
}).on("volumechange.mediaplayerevent", function (e) { }).on("volumechange.mediaplayerevent", function (e) {
var vol = this.volume; var vol = this.volume;

View file

@ -1,6 +1,6 @@
(function ($, document) { (function ($, document) {
var view = LibraryBrowser.getDefaultItemsView('Thumb', 'ThumbCard'); var view = LibraryBrowser.getDefaultItemsView('Thumb', 'Thumb');
// The base query options // The base query options
var query = { var query = {

View file

@ -1,6 +1,6 @@
(function ($, document) { (function ($, document) {
var view = LibraryBrowser.getDefaultItemsView('Thumb', 'ThumbCard'); var view = LibraryBrowser.getDefaultItemsView('Thumb', 'Thumb');
// The base query options // The base query options
var query = { var query = {

View file

@ -99,7 +99,8 @@
title: item.Name, title: item.Name,
showRemoveFromPlaylist: true, showRemoveFromPlaylist: true,
playFromHere: true, playFromHere: true,
defaultAction: 'playallfromhere' defaultAction: 'playallfromhere',
smallIcon: true
}); });
} }

View file

@ -36,7 +36,7 @@ var Dashboard = {
$.mobile.popup.prototype.options.transition = "pop"; $.mobile.popup.prototype.options.transition = "pop";
if ($.browser.mobile) { if ($.browser.mobile) {
$.mobile.defaultPageTransition = "slide"; $.mobile.defaultPageTransition = "none";
} else { } else {
$.mobile.defaultPageTransition = "none"; $.mobile.defaultPageTransition = "none";
} }
@ -45,6 +45,9 @@ var Dashboard = {
// Make panels a little larger than the defaults // Make panels a little larger than the defaults
$.mobile.panel.prototype.options.classes.modalOpen = "largePanelModalOpen ui-panel-dismiss-open"; $.mobile.panel.prototype.options.classes.modalOpen = "largePanelModalOpen ui-panel-dismiss-open";
$.mobile.panel.prototype.options.classes.panel = "largePanel ui-panel"; $.mobile.panel.prototype.options.classes.panel = "largePanel ui-panel";
$.event.special.swipe.verticalDistanceThreshold = 40;
$.mobile.loader.prototype.options.disabled = true;
}, },
isConnectMode: function () { isConnectMode: function () {
@ -92,7 +95,7 @@ var Dashboard = {
} }
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
if (!Dashboard.suppressAjaxErrors && data.type != 'GET') { if (!Dashboard.suppressAjaxErrors && data.type != 'GET' && !AppInfo.isNativeApp) {
setTimeout(function () { setTimeout(function () {
@ -731,7 +734,7 @@ var Dashboard = {
if (item.selected) { if (item.selected) {
menuHtml += '<a class="sidebarLink selectedSidebarLink" href="' + item.href + '">'; menuHtml += '<a class="sidebarLink selectedSidebarLink" href="' + item.href + '">';
} else { } else {
menuHtml += '<a data-transition="none" class="sidebarLink" href="' + item.href + '">'; menuHtml += '<a class="sidebarLink" href="' + item.href + '">';
} }
var icon = item.icon; var icon = item.icon;
@ -765,7 +768,7 @@ var Dashboard = {
html += '<div data-role="panel" id="dashboardPanel" class="dashboardPanel" data-position="left" data-display="overlay" data-position-fixed="true" data-theme="a">'; html += '<div data-role="panel" id="dashboardPanel" class="dashboardPanel" data-position="left" data-display="overlay" data-position-fixed="true" data-theme="a">';
html += '<p class="libraryPanelHeader" style="margin: 15px 0 15px 20px;"><a href="index.html" data-transition="none" class="imageLink"><img src="css/images/mblogoicon.png" /><span style="color:#333;">EMBY</span></a></p>'; html += '<p class="libraryPanelHeader" style="margin: 15px 0 15px 20px;"><a href="index.html" class="imageLink"><img src="css/images/mblogoicon.png" /><span style="color:#333;">EMBY</span></a></p>';
html += '<div class="sidebarLinks">'; html += '<div class="sidebarLinks">';
html += menuHtml; html += menuHtml;
@ -1982,7 +1985,7 @@ $(document).on('pagecreate', ".page", function () {
Dashboard.firePageEvent(page, 'pageinitdepends'); Dashboard.firePageEvent(page, 'pageinitdepends');
} }
$('.localnav a, .libraryViewNav a').attr('data-transition', 'none'); //$('.localnav a, .libraryViewNav a').attr('data-transition', 'none');
}).on('pagebeforeshow', ".page", function () { }).on('pagebeforeshow', ".page", function () {

View file

@ -1,6 +1,6 @@
(function ($, document) { (function ($, document) {
var view = LibraryBrowser.getDefaultItemsView('Thumb', 'ThumbCard'); var view = LibraryBrowser.getDefaultItemsView('Thumb', 'Thumb');
// The base query options // The base query options
var query = { var query = {

View file

@ -2,9 +2,6 @@
var PlayerName = "Chromecast"; var PlayerName = "Chromecast";
var ApplicationID = "2D4B1DA3"; var ApplicationID = "2D4B1DA3";
var currentPairingDeviceId;
var currentPairedDeviceId;
var currentDeviceFriendlyName;
var currentWebAppSession; var currentWebAppSession;
var currentDevice; var currentDevice;
@ -87,7 +84,7 @@
accessToken: ApiClient.accessToken(), accessToken: ApiClient.accessToken(),
serverAddress: ApiClient.serverAddress(), serverAddress: ApiClient.serverAddress(),
maxBitrate: bitrateSetting, maxBitrate: bitrateSetting,
receiverName: currentDeviceFriendlyName receiverName: currentDevice.getFriendlyName()
}); });
getEndpointInfo().done(function (endpoint) { getEndpointInfo().done(function (endpoint) {
@ -462,32 +459,45 @@
MediaController.removeActivePlayer(PlayerName); MediaController.removeActivePlayer(PlayerName);
} }
function setupWebAppSession(device, session) { function onWebAppSessionConnect(webAppSession, device) {
// hold on to a reference currentWebAppSession = webAppSession;
currentWebAppSession = session.acquire();
currentWebAppSession.on('message', handleMessage);
currentWebAppSession.connect().success(function () {
console.log('session.connect succeeded'); console.log('session.connect succeeded');
currentWebAppSession.setWebAppSessionListener(); webAppSession.setWebAppSessionListener();
currentWebAppSession.on('disconnect', handleSessionDisconnect);
MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device)); MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device));
currentDeviceFriendlyName = device.getFriendlyName();
currentPairedDeviceId = device.getId();
currentDevice = device; currentDevice = device;
$(castPlayer).trigger('connect'); $(castPlayer).trigger('connect');
sendIdentifyMessage();
}
function setupWebAppSession(device, session, connectToSession) {
// hold on to a reference
var currentSession = session.acquire();
currentSession.on('message', handleMessage);
currentSession.on('disconnect', handleSessionDisconnect);
if (connectToSession || $.browser.safari) {
currentSession.connect().success(function () {
onWebAppSessionConnect(currentSession, device);
}).error(handleSessionError);
} else {
onWebAppSessionConnect(currentSession, device);
}
}
function sendIdentifyMessage() {
sendMessageToDevice({ sendMessageToDevice({
options: {}, options: {},
command: 'Identify' command: 'Identify'
}); });
}).error(handleSessionError);
} }
function handleSessionError() { function handleSessionError() {
@ -508,17 +518,7 @@
session.release(); session.release();
} }
if (currentDevice != null) {
currentDevice.off("ready");
currentDevice.off("disconnect");
currentDevice.disconnect();
}
currentWebAppSession = null; currentWebAppSession = null;
currentPairedDeviceId = null;
currentDeviceFriendlyName = null;
currentDevice = null;
} }
function tryLaunchWebSession(device) { function tryLaunchWebSession(device) {
@ -527,7 +527,7 @@
device.getWebAppLauncher().launchWebApp(ApplicationID).success(function (session) { device.getWebAppLauncher().launchWebApp(ApplicationID).success(function (session) {
console.log('launchWebApp success. calling onSessionConnected'); console.log('launchWebApp success. calling onSessionConnected');
setupWebAppSession(device, session); setupWebAppSession(device, session, true);
}).error(function (err1) { }).error(function (err1) {
@ -544,7 +544,7 @@
device.getWebAppLauncher().joinWebApp(ApplicationID).success(function (session) { device.getWebAppLauncher().joinWebApp(ApplicationID).success(function (session) {
console.log('joinWebApp success. calling onSessionConnected'); console.log('joinWebApp success. calling onSessionConnected');
setupWebAppSession(device, session); setupWebAppSession(device, session, false);
}).error(function (err) { }).error(function (err) {
@ -563,15 +563,16 @@
function launchWebApp(device) { function launchWebApp(device) {
if (currentWebAppSession) {
cleanupSession();
}
tryJoinWebSession(device, true); tryJoinWebSession(device, true);
} }
function onDeviceReady(device) { function onDeviceReady(device) {
if (currentPairingDeviceId != device.getId()) { device.off("ready");
console.log('device ready fired for a different device. ignoring.');
return;
}
console.log('creating webAppSession'); console.log('creating webAppSession');
@ -600,11 +601,13 @@
self.tryPairWithDevice = function (device, deferred) { self.tryPairWithDevice = function (device, deferred) {
var deviceId = device.getId();
currentPairingDeviceId = deviceId;
console.log('Will attempt to connect to Chromecast'); console.log('Will attempt to connect to Chromecast');
device.on("disconnect", function () {
device.off("ready");
device.off("disconnect");
});
if (device.isReady()) { if (device.isReady()) {
console.log('Device is already ready, calling onDeviceReady'); console.log('Device is already ready, calling onDeviceReady');
onDeviceReady(device); onDeviceReady(device);
@ -617,11 +620,6 @@
onDeviceReady(device); onDeviceReady(device);
}); });
device.on("disconnect", function () {
device.off("ready");
device.off("disconnect");
});
console.log('Calling device.connect'); console.log('Calling device.connect');
device.connect(); device.connect();
} }
@ -629,11 +627,12 @@
$(MediaController).on('playerchange', function (e, newPlayer, newTarget) { $(MediaController).on('playerchange', function (e, newPlayer, newTarget) {
if (currentPairedDeviceId) { if (currentDevice) {
if (newTarget.id != currentPairedDeviceId) { if (newTarget.id != currentDevice.getId()) {
if (currentWebAppSession) { if (currentWebAppSession) {
console.log('Disconnecting from chromecast'); console.log('Disconnecting from chromecast');
cleanupSession(); currentDevice.disconnect();
currentDevice = null;
} }
} }
} }

View file

@ -37,6 +37,10 @@
validateFeature(getPremiumUnlockFeatureId(), deferred); validateFeature(getPremiumUnlockFeatureId(), deferred);
} }
function validateServerManagement(deferred) {
deferred.resolve();
}
function getRegistrationInfo(feature, enableSupporterUnlock) { function getRegistrationInfo(feature, enableSupporterUnlock) {
if (!enableSupporterUnlock) { if (!enableSupporterUnlock) {
@ -224,6 +228,8 @@
validatePlayback(deferred); validatePlayback(deferred);
} else if (name == 'livetv') { } else if (name == 'livetv') {
validateLiveTV(deferred); validateLiveTV(deferred);
} else if (name == 'manageserver') {
validateServerManagement(deferred);
} else { } else {
deferred.resolve(); deferred.resolve();
} }