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

fix xbox one browser access

This commit is contained in:
Luke Pulverenti 2015-05-06 23:11:51 -04:00
parent 0a24cd2dc6
commit 173773d5bc
22 changed files with 1229 additions and 172 deletions

View file

@ -119,7 +119,16 @@
}
}
$(document).on('pageshow', "#connectLoginPage", function () {
$(document).on('pageinit', "#connectLoginPage", function () {
var page = this;
$('.btnSkipConnect', page).on('click', function() {
Dashboard.navigate('connectlogin.html?mode=manualserver');
});
}).on('pageshow', "#connectLoginPage", function () {
var page = this;

View file

@ -1177,6 +1177,8 @@
var chapters = item.Chapters || [];
var maxWwidth = LibraryBrowser.getPosterViewSizes().thumbWidth;
for (var i = 0, length = chapters.length; i < length; i++) {
if (limit && i >= limit) {
@ -1198,7 +1200,7 @@
if (chapter.ImageTag) {
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
maxWidth: 210,
maxWidth: maxWwidth,
tag: chapter.ImageTag,
type: "Chapter",
index: i
@ -1397,6 +1399,8 @@
var html = '';
var maxWwidth = LibraryBrowser.getPosterViewSizes().thumbWidth;
for (var i = 0, length = items.length; i < length; i++) {
if (limit && i >= limit) {
@ -1423,7 +1427,7 @@
if (imageTags.Primary) {
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
maxWidth: 210,
maxWidth: maxWwidth,
tag: imageTags.Primary,
type: "primary"
});

View file

@ -945,6 +945,63 @@
return itemCommands;
},
screenWidth: function () {
var screenWidth = $(window).width();
if (!AppInfo.isTouchPreferred) {
screenWidth = window.screen.availWidth;
}
return screenWidth;
},
getPostersPerRow: function () {
var screenWidth = LibraryBrowser.screenWidth();
var div = $('<div class="card squareCard"><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
var square = screenWidth / $('.cardImage', div).innerWidth();
div.remove();
div = $('<div class="card backdropCard">><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
var thumb = screenWidth / $('.cardImage', div).innerWidth();
div.remove();
div = $('<div class="card portraitCard">><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
var poster = screenWidth / $('.cardImage', div).innerWidth();
div.remove();
return {
thumb: thumb,
poster: poster,
square: square
};
},
getPosterViewSizes: function () {
var imagesPerRow = LibraryBrowser.getPostersPerRow();
var screenWidth = LibraryBrowser.screenWidth();
if (AppInfo.hasLowImageBandwidth) {
screenWidth *= .95;
} else {
screenWidth *= 1.25;
}
var thumbWidth = screenWidth / imagesPerRow.thumb;
var posterWidth = screenWidth / imagesPerRow.poster;
var squareSize = screenWidth / imagesPerRow.square;
return {
thumbWidth: parseInt(thumbWidth),
posterWidth: parseInt(posterWidth),
squareSize: parseInt(squareSize)
};
},
getPosterViewHtml: function (options) {
var items = options.items;
@ -978,6 +1035,12 @@
}
}
var sizes = LibraryBrowser.getPosterViewSizes();
var thumbWidth = sizes.thumbWidth;
var posterWidth = sizes.posterWidth;
var squareSize = sizes.squareSize;
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
@ -1044,13 +1107,12 @@
var forceName = false;
var downloadHeight = 576;
var enableImageEnhancers = options.enableImageEnhancers !== false;
if (options.autoThumb && item.ImageTags && item.ImageTags.Primary && item.PrimaryImageAspectRatio && item.PrimaryImageAspectRatio >= 1.5) {
height = 400;
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
width = posterWidth;
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
imgUrl = ApiClient.getImageUrl(item.Id, {
type: "Primary",
@ -1064,7 +1126,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1073,7 +1135,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Backdrop",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.BackdropImageTags[0],
enableImageEnhancers: enableImageEnhancers
});
@ -1082,7 +1144,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1100,7 +1162,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.SeriesThumbImageTag,
enableImageEnhancers: enableImageEnhancers
});
@ -1109,7 +1171,7 @@
imgUrl = ApiClient.getThumbImageUrl(item.ParentThumbItemId, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
enableImageEnhancers: enableImageEnhancers
});
@ -1117,7 +1179,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Backdrop",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.BackdropImageTags[0],
enableImageEnhancers: enableImageEnhancers
});
@ -1126,8 +1188,8 @@
} else if (item.ImageTags && item.ImageTags.Primary) {
height = 400;
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
width = posterWidth;
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
imgUrl = ApiClient.getImageUrl(item.Id, {
type: "Primary",
@ -1140,18 +1202,16 @@
}
else if (item.ParentPrimaryImageTag) {
height = 400;
imgUrl = ApiClient.getImageUrl(item.ParentPrimaryImageItemId, {
type: "Primary",
height: height,
width: posterWidth,
tag: item.ParentPrimaryImageTag,
enableImageEnhancers: enableImageEnhancers
});
}
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
height = 220;
height = squareSize;
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
imgUrl = ApiClient.getScaledImageUrl(item.AlbumId, {
@ -1167,7 +1227,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1177,7 +1237,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Backdrop",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.BackdropImageTags[0],
enableImageEnhancers: enableImageEnhancers
});
@ -1186,7 +1246,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1195,7 +1255,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.SeriesThumbImageTag,
enableImageEnhancers: enableImageEnhancers
});
@ -1204,7 +1264,7 @@
imgUrl = ApiClient.getThumbImageUrl(item, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
enableImageEnhancers: enableImageEnhancers
});

View file

@ -912,6 +912,17 @@
return false;
}
function resetCardImage() {
this.style.backgroundImage = "url('css/images/empty.png')";
}
function resetImages(page) {
//$('cardImage', page).remove();
$('.cardImage', page).each(resetCardImage);
}
$(document).on('pageinit', ".libraryPage", function () {
var page = this;
@ -964,6 +975,11 @@
hideSelections(page);
$('.viewTabButton:first', page).trigger('click');
}).on('pagebeforehide', ".libraryPage", function () {
var page = this;
resetImages(page);
});
function renderUserDataChanges(card, userData) {

View file

@ -1,10 +1,10 @@
(function (window, document, $) {
(function (window, document, $, devicePixelRatio) {
function renderHeader(user) {
var html = '<div class="viewMenuBar ui-bar-b">';
if (($.browser.safari && $.browser.mobile && window.navigator.standalone) || Dashboard.isRunningInCordova()) {
if (($.browser.safari && window.navigator.standalone) || Dashboard.isRunningInCordova()) {
html += '<a data-rel="back" data-role="none" href="#" class="headerButton headerButtonLeft headerBackButton"><div class="fa fa-arrow-circle-o-left"></div></a>';
}
@ -40,9 +40,9 @@
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none" style="visibility:hidden;"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
}
if (user.name) {
html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">';
if (user.imageUrl) {
@ -80,12 +80,12 @@
function bindMenuEvents() {
if ($.browser.mobile) {
if (AppInfo.isTouchPreferred) {
$('.libraryMenuButton').on('mousedown', function () {
$('.libraryMenuButton').on('click', function () {
showLibraryMenu(false);
});
$('.dashboardMenuButton').on('mousedown', function () {
$('.dashboardMenuButton').on('click', function () {
showDashboardMenu(false);
});
@ -96,10 +96,7 @@
// grab an element
var viewMenuBar = document.getElementsByClassName("viewMenuBar")[0];
// construct an instance of Headroom, passing the element
var headroom = new Headroom(viewMenuBar);
// initialise
headroom.init();
initHeadRoom(viewMenuBar);
}
function getItemHref(item, context) {
@ -263,7 +260,7 @@
html += '<div class="sidebarLinks librarySidebarLinks">';
var showUserAtTop = $.browser.mobile;
var showUserAtTop = AppInfo.isTouchPreferred;
if (showUserAtTop) {
@ -545,16 +542,25 @@
$(document).scrollTop(0);
}
$('.libraryViewNav', page).each(function() {
// construct an instance of Headroom, passing the element
var headroom = new Headroom(this);
// initialise
headroom.init();
$('.libraryViewNav', page).each(function () {
initHeadRoom(this);
});
});
function initHeadRoom(elem) {
if (!AppInfo.enableHeadRoom) {
return;
}
// construct an instance of Headroom, passing the element
var headroom = new Headroom(elem);
// initialise
headroom.init();
}
function initializeApiClient(apiClient) {
$(apiClient).off('websocketmessage.librarymenu', onWebSocketMessage).on('websocketmessage.librarymenu', onWebSocketMessage);
@ -573,7 +579,7 @@
});
})(window, document, jQuery);
})(window, document, jQuery, window.devicePixelRatio);
$.fn.createHoverTouch = function () {

View file

@ -419,14 +419,16 @@
});
}
$('.tvGuideHeader', page).each(function () {
if (AppInfo.enableHeadRoom) {
$('.tvGuideHeader', page).each(function () {
// construct an instance of Headroom, passing the element
var headroom = new Headroom(this);
// initialise
headroom.init();
// construct an instance of Headroom, passing the element
var headroom = new Headroom(this);
// initialise
headroom.init();
});
});
}
}).on('pageshow', "#liveTvGuidePage", function () {

View file

@ -90,6 +90,7 @@
function onPopupOpen(elem) {
elem.popup("open").parents(".ui-popup-container").css("margin-top", 30);
// TODO: With iOS 8 this might not be required anymore
if ($.browser.safari) {
$('.itemVideo').css('visibility', 'hidden');
}

View file

@ -26,7 +26,7 @@
self.getTargets = function () {
var targets = [{
name: 'My Browser',
name: Globalize.translate('MyDevice'),
id: ConnectionManager.deviceId(),
playerName: self.name,
playableMediaTypes: ['Audio', 'Video'],
@ -139,6 +139,13 @@
VideoCodec: 'h264',
AudioCodec: 'aac,mp3'
});
// TODO: Test this
//profile.DirectPlayProfiles.push({
// Container: 'mov',
// Type: 'Video',
// VideoCodec: 'h264',
// AudioCodec: 'aac,mp3'
//});
}
profile.DirectPlayProfiles.push({
@ -208,7 +215,6 @@
profile.ContainerProfiles = [];
var audioConditions = [];
var videoAudioAacConditions = [];
var videoAudioMp3Conditions = [];
var maxAudioChannels = $.browser.msie || $.browser.safari ?
@ -222,7 +228,6 @@
};
audioConditions.push(channelCondition);
videoAudioAacConditions.push(channelCondition);
videoAudioMp3Conditions.push(channelCondition);
profile.CodecProfiles = [];
@ -239,22 +244,32 @@
});
}
videoAudioAacConditions.push({
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'LC'
});
videoAudioAacConditions.push({
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'HE-AAC'
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac',
Container: 'mkv,mov',
Conditions: [
channelCondition,
{
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'HE-AAC'
},
{
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'LC'
}
]
});
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac',
Conditions: videoAudioAacConditions
Container: 'mp4,m4v',
Conditions: [
channelCondition
]
});
profile.CodecProfiles.push({
@ -319,6 +334,18 @@
MimeType: 'video/mp4'
});
//profile.ResponseProfiles.push({
// Type: 'Video',
// Container: 'mkv',
// MimeType: 'video/webm'
//});
profile.ResponseProfiles.push({
Type: 'Video',
Container: 'mov',
MimeType: 'video/webm'
});
return profile;
};
@ -833,7 +860,10 @@
var deviceProfile = self.getDeviceProfile();
Dashboard.showLoadingMsg();
if (item.MediaType === "Video") {
Dashboard.showModalLoadingMsg();
}
getPlaybackInfo(item.Id, deviceProfile, startPosition).done(function (playbackInfoResult) {
@ -856,7 +886,7 @@
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback);
}
} else {
Dashboard.hideLoadingMsg();
Dashboard.hideModalLoadingMsg();
showPlaybackInfoErrorMessage('NoCompatibleStream');
}
}
@ -866,7 +896,7 @@
function playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback) {
Dashboard.hideLoadingMsg();
Dashboard.hideModalLoadingMsg();
self.currentMediaSource = mediaSource;
self.currentItem = item;

View file

@ -128,12 +128,12 @@
var id = this.getAttribute('data-serverid');
if (id == 'new') {
window.location = 'connectlogin.html?mode=manualserver';
Dashboard.navigate('connectlogin.html?mode=manualserver');
return;
}
if (id == 'connect') {
window.location = 'connectlogin.html?mode=connect';
Dashboard.navigate('connectlogin.html?mode=connect');
return;
}

View file

@ -368,6 +368,10 @@ var Dashboard = {
showFooterNotification: function (options) {
if (Dashboard.isRunningInCordova()) {
return;
}
var removeOnHide = !options.id;
options.id = options.id || "notification" + new Date().getTime() + parseInt(Math.random());
@ -441,6 +445,29 @@ var Dashboard = {
$.mobile.loading("hide");
},
getModalLoadingMsg: function () {
var elem = $('.modalLoading');
if (!elem.length) {
elem = $('<div class="modalLoading"></div>').appendTo(document.body);
}
return elem;
},
showModalLoadingMsg: function () {
Dashboard.showLoadingMsg();
Dashboard.getModalLoadingMsg().show();
},
hideModalLoadingMsg: function () {
Dashboard.getModalLoadingMsg().hide();
Dashboard.hideLoadingMsg();
},
processPluginConfigurationUpdateResult: function () {
Dashboard.hideLoadingMsg();
@ -613,7 +640,7 @@ var Dashboard = {
var url = user.imageUrl;
if (user.supportsImageParams) {
url += "&width=" + (imgWidth * Math.max(devicePixelRatio || 1, 2));
url += "&width=" + (imgWidth * Math.max(window.devicePixelRatio || 1, 2));
}
html += '<img style="max-width:' + imgWidth + 'px;vertical-align:middle;margin-right:.5em;border-radius: 50px;" src="' + url + '" />';
@ -1330,7 +1357,7 @@ var Dashboard = {
quality -= 15;
}
if ($.browser.safari && $.browser.mobile) {
if (AppInfo.hasLowImageBandwidth) {
quality -= 10;
@ -1416,11 +1443,34 @@ var Dashboard = {
}
};
var AppInfo = {};
(function () {
if (!window.WebSocket) {
function isTouchDevice() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
alert(Globalize.translate('MessageBrowserDoesNotSupportWebSockets'));
function setAppInfo() {
if (isTouchDevice()) {
AppInfo.isTouchPreferred = true;
}
if ($.browser.safari) {
if ($.browser.mobile) {
AppInfo.hasLowImageBandwidth = true;
}
}
else {
if (!$.browser.tv) {
AppInfo.enableHeadRoom = true;
}
}
}
function initializeApiClient(apiClient) {
@ -1487,6 +1537,12 @@ var Dashboard = {
function onReady() {
//FastClick.attach(document.body);
if (AppInfo.hasLowImageBandwidth) {
$(document.body).addClass('largeCardMargin');
}
var videoPlayerHtml = '<div id="mediaPlayer" data-theme="b" class="ui-bar-b" style="display: none;">';
videoPlayerHtml += '<div class="videoBackdrop">';
@ -1589,21 +1645,12 @@ var Dashboard = {
e.preventDefault();
return false;
});
function isTouchDevice() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
if (isTouchDevice()) {
$(document.body).addClass('touch');
}
}
if (Dashboard.isRunningInCordova()) {
setAppInfo();
createConnectionManager();
createConnectionManager();
if (Dashboard.isRunningInCordova()) {
document.addEventListener("deviceready", function () {
@ -1613,8 +1660,6 @@ var Dashboard = {
} else {
createConnectionManager();
$(onReady);
}
})();
@ -1677,13 +1722,13 @@ $(document).on('pagecreate', ".page", function () {
var isConnectMode = Dashboard.isConnectMode();
if (isConnectMode) {
if (!Dashboard.isServerlessPage()) {
Dashboard.logout();
return;
}
}
if (this.id !== "loginPage" && !page.hasClass('forgotPasswordPage') && !page.hasClass('wizardPage') && !isConnectMode) {
console.log('Not logged into server. Redirecting to login.');

View file

@ -47,7 +47,7 @@
var val = store.getItem('enableThemeSongs-' + userId);
// For bandwidth
return val == '1' || (val != '0' && !$.browser.mobile);
return val == '1' || (val != '0' && MediaPlayer.canAutoPlayAudio());
}
function getPlayer() {