mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
use shared components for quality options
This commit is contained in:
parent
da548f4d49
commit
965dc0b07b
9 changed files with 565 additions and 522 deletions
|
@ -15,12 +15,12 @@
|
|||
},
|
||||
"devDependencies": {},
|
||||
"ignore": [],
|
||||
"version": "1.0.2",
|
||||
"_release": "1.0.2",
|
||||
"version": "1.0.5",
|
||||
"_release": "1.0.5",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "1.0.2",
|
||||
"commit": "a4909b1637879d7e52ce9eaba8247ad98b690de9"
|
||||
"tag": "1.0.5",
|
||||
"commit": "ff6d4ba01de70b907dfa51b36aee6c63f64685c9"
|
||||
},
|
||||
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
|
||||
"_target": "~1.0.0",
|
||||
|
|
|
@ -225,6 +225,8 @@
|
|||
}]
|
||||
});
|
||||
|
||||
var videoAudioChannels = browser.safari ? '2' : '6';
|
||||
|
||||
profile.CodecProfiles.push({
|
||||
Type: 'VideoAudio',
|
||||
Codec: 'aac',
|
||||
|
@ -234,6 +236,17 @@
|
|||
Condition: 'NotEquals',
|
||||
Property: 'AudioProfile',
|
||||
Value: 'HE-AAC'
|
||||
},
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioChannels',
|
||||
Value: videoAudioChannels
|
||||
},
|
||||
{
|
||||
Condition: 'Equals',
|
||||
Property: 'IsSecondaryAudio',
|
||||
Value: 'false',
|
||||
IsRequired: 'false'
|
||||
}
|
||||
// Disabling this is going to require us to learn why it was disabled in the first place
|
||||
//,
|
||||
|
@ -252,7 +265,13 @@
|
|||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioChannels',
|
||||
Value: '6'
|
||||
Value: videoAudioChannels
|
||||
},
|
||||
{
|
||||
Condition: 'Equals',
|
||||
Property: 'IsSecondaryAudio',
|
||||
Value: 'false',
|
||||
IsRequired: 'false'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
@ -260,6 +279,11 @@
|
|||
profile.CodecProfiles.push({
|
||||
Type: 'VideoAudio',
|
||||
Conditions: [
|
||||
{
|
||||
Condition: 'LessThanEqual',
|
||||
Property: 'AudioChannels',
|
||||
Value: videoAudioChannels
|
||||
},
|
||||
{
|
||||
Condition: 'Equals',
|
||||
Property: 'IsSecondaryAudio',
|
||||
|
|
81
dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js
vendored
Normal file
81
dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
define([], function () {
|
||||
|
||||
function getVideoQualityOptions(maxStreamingBitrate, videoWidth) {
|
||||
|
||||
var maxAllowedWidth = videoWidth || 4096;
|
||||
//var maxAllowedHeight = videoHeight || 2304;
|
||||
|
||||
var options = [];
|
||||
|
||||
// Some 1080- videos are reported as 1912?
|
||||
if (maxAllowedWidth >= 1900) {
|
||||
|
||||
options.push({ name: '1080p - 40Mbps', maxHeight: 1080, bitrate: 40000000 });
|
||||
options.push({ name: '1080p - 35Mbps', maxHeight: 1080, bitrate: 35000000 });
|
||||
options.push({ name: '1080p - 30Mbps', maxHeight: 1080, bitrate: 30000000 });
|
||||
options.push({ name: '1080p - 25Mbps', maxHeight: 1080, bitrate: 25000000 });
|
||||
options.push({ name: '1080p - 20Mbps', maxHeight: 1080, bitrate: 20000000 });
|
||||
options.push({ name: '1080p - 15Mbps', maxHeight: 1080, bitrate: 15000000 });
|
||||
options.push({ name: '1080p - 10Mbps', maxHeight: 1080, bitrate: 10000001 });
|
||||
options.push({ name: '1080p - 8Mbps', maxHeight: 1080, bitrate: 8000001 });
|
||||
options.push({ name: '1080p - 6Mbps', maxHeight: 1080, bitrate: 6000001 });
|
||||
options.push({ name: '1080p - 5Mbps', maxHeight: 1080, bitrate: 5000001 });
|
||||
options.push({ name: '1080p - 4Mbps', maxHeight: 1080, bitrate: 4000002 });
|
||||
|
||||
} else if (maxAllowedWidth >= 1260) {
|
||||
options.push({ name: '720p - 10Mbps', maxHeight: 720, bitrate: 10000000 });
|
||||
options.push({ name: '720p - 8Mbps', maxHeight: 720, bitrate: 8000000 });
|
||||
options.push({ name: '720p - 6Mbps', maxHeight: 720, bitrate: 6000000 });
|
||||
options.push({ name: '720p - 5Mbps', maxHeight: 720, bitrate: 5000000 });
|
||||
|
||||
} else if (maxAllowedWidth >= 700) {
|
||||
options.push({ name: '480p - 4Mbps', maxHeight: 480, bitrate: 4000001 });
|
||||
options.push({ name: '480p - 3Mbps', maxHeight: 480, bitrate: 3000001 });
|
||||
options.push({ name: '480p - 2.5Mbps', maxHeight: 480, bitrate: 2500000 });
|
||||
options.push({ name: '480p - 2Mbps', maxHeight: 480, bitrate: 2000001 });
|
||||
options.push({ name: '480p - 1.5Mbps', maxHeight: 480, bitrate: 1500001 });
|
||||
}
|
||||
|
||||
if (maxAllowedWidth >= 1260) {
|
||||
options.push({ name: '720p - 4Mbps', maxHeight: 720, bitrate: 4000000 });
|
||||
options.push({ name: '720p - 3Mbps', maxHeight: 720, bitrate: 3000000 });
|
||||
options.push({ name: '720p - 2Mbps', maxHeight: 720, bitrate: 2000000 });
|
||||
|
||||
// The extra 1 is because they're keyed off the bitrate value
|
||||
options.push({ name: '720p - 1.5Mbps', maxHeight: 720, bitrate: 1500000 });
|
||||
options.push({ name: '720p - 1Mbps', maxHeight: 720, bitrate: 1000001 });
|
||||
}
|
||||
|
||||
options.push({ name: '480p - 1.0Mbps', maxHeight: 480, bitrate: 1000000 });
|
||||
options.push({ name: '480p - 720kbps', maxHeight: 480, bitrate: 720000 });
|
||||
options.push({ name: '480p - 420kbps', maxHeight: 480, bitrate: 420000 });
|
||||
options.push({ name: '360p', maxHeight: 360, bitrate: 400000 });
|
||||
options.push({ name: '240p', maxHeight: 240, bitrate: 320000 });
|
||||
options.push({ name: '144p', maxHeight: 144, bitrate: 192000 });
|
||||
|
||||
if (maxStreamingBitrate) {
|
||||
var selectedIndex = -1;
|
||||
for (var i = 0, length = options.length; i < length; i++) {
|
||||
|
||||
var option = options[i];
|
||||
|
||||
if (selectedIndex == -1 && option.bitrate <= maxStreamingBitrate) {
|
||||
selectedIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedIndex == -1) {
|
||||
|
||||
selectedIndex = options.length - 1;
|
||||
}
|
||||
|
||||
options[selectedIndex].selected = true;
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
return {
|
||||
getVideoQualityOptions: getVideoQualityOptions
|
||||
};
|
||||
});
|
|
@ -29,14 +29,14 @@
|
|||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": [],
|
||||
"homepage": "https://github.com/PolymerElements/iron-behaviors",
|
||||
"homepage": "https://github.com/polymerelements/iron-behaviors",
|
||||
"_release": "1.0.12",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.12",
|
||||
"commit": "657f526a2382a659cdf4e13be87ecc89261588a3"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-behaviors.git",
|
||||
"_source": "git://github.com/polymerelements/iron-behaviors.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/iron-behaviors"
|
||||
"_originalSource": "polymerelements/iron-behaviors"
|
||||
}
|
|
@ -36,7 +36,7 @@
|
|||
"tag": "v1.0.8",
|
||||
"commit": "e9a66727f3da0446f04956d4e4f1dcd51cdec2ff"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-selector.git",
|
||||
"_source": "git://github.com/polymerelements/iron-selector.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/iron-selector"
|
||||
"_originalSource": "polymerelements/iron-selector"
|
||||
}
|
|
@ -140,6 +140,8 @@
|
|||
|
||||
self.showQualityFlyout = function () {
|
||||
|
||||
require(['qualityoptions', 'actionsheet'], function (qualityoptions) {
|
||||
|
||||
var currentSrc = self.getCurrentSrc(self.currentMediaRenderer).toLowerCase();
|
||||
var isStatic = currentSrc.indexOf('static=true') != -1;
|
||||
|
||||
|
@ -147,9 +149,8 @@
|
|||
return stream.Type == "Video";
|
||||
})[0];
|
||||
var videoWidth = videoStream ? videoStream.Width : null;
|
||||
var videoHeight = videoStream ? videoStream.Height : null;
|
||||
|
||||
var options = self.getVideoQualityOptions(videoWidth, videoHeight);
|
||||
var options = qualityoptions.getVideoQualityOptions(AppSettings.maxStreamingBitrate(), videoWidth);
|
||||
|
||||
if (isStatic) {
|
||||
options[0].name = "Direct";
|
||||
|
@ -173,8 +174,6 @@
|
|||
return o.selected;
|
||||
});
|
||||
selectedId = selectedId.length ? selectedId[0].bitrate : null;
|
||||
require(['actionsheet'], function () {
|
||||
|
||||
ActionSheetElement.show({
|
||||
items: menuItems,
|
||||
positionTo: $('.videoQualityButton')[0],
|
||||
|
|
|
@ -36,92 +36,21 @@
|
|||
return targets;
|
||||
};
|
||||
|
||||
self.getVideoQualityOptions = function (videoWidth, videoHeight) {
|
||||
self.getDeviceProfile = function (maxHeight) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
require(['qualityoptions'], function (qualityoptions) {
|
||||
|
||||
var bitrateSetting = AppSettings.maxStreamingBitrate();
|
||||
|
||||
var maxAllowedWidth = videoWidth || 4096;
|
||||
var maxAllowedHeight = videoHeight || 2304;
|
||||
|
||||
var options = [];
|
||||
|
||||
// Some 1080- videos are reported as 1912?
|
||||
if (maxAllowedWidth >= 1900) {
|
||||
|
||||
options.push({ name: '1080p - 40Mbps', maxHeight: 1080, bitrate: 40000000 });
|
||||
options.push({ name: '1080p - 35Mbps', maxHeight: 1080, bitrate: 35000000 });
|
||||
options.push({ name: '1080p - 30Mbps', maxHeight: 1080, bitrate: 30000000 });
|
||||
options.push({ name: '1080p - 25Mbps', maxHeight: 1080, bitrate: 25000000 });
|
||||
options.push({ name: '1080p - 20Mbps', maxHeight: 1080, bitrate: 20000000 });
|
||||
options.push({ name: '1080p - 15Mbps', maxHeight: 1080, bitrate: 15000000 });
|
||||
options.push({ name: '1080p - 10Mbps', maxHeight: 1080, bitrate: 10000001 });
|
||||
options.push({ name: '1080p - 8Mbps', maxHeight: 1080, bitrate: 8000001 });
|
||||
options.push({ name: '1080p - 6Mbps', maxHeight: 1080, bitrate: 6000001 });
|
||||
options.push({ name: '1080p - 5Mbps', maxHeight: 1080, bitrate: 5000001 });
|
||||
options.push({ name: '1080p - 4Mbps', maxHeight: 1080, bitrate: 4000002 });
|
||||
|
||||
} else if (maxAllowedWidth >= 1260) {
|
||||
options.push({ name: '720p - 10Mbps', maxHeight: 720, bitrate: 10000000 });
|
||||
options.push({ name: '720p - 8Mbps', maxHeight: 720, bitrate: 8000000 });
|
||||
options.push({ name: '720p - 6Mbps', maxHeight: 720, bitrate: 6000000 });
|
||||
options.push({ name: '720p - 5Mbps', maxHeight: 720, bitrate: 5000000 });
|
||||
|
||||
} else if (maxAllowedWidth >= 700) {
|
||||
options.push({ name: '480p - 4Mbps', maxHeight: 480, bitrate: 4000001 });
|
||||
options.push({ name: '480p - 3Mbps', maxHeight: 480, bitrate: 3000001 });
|
||||
options.push({ name: '480p - 2.5Mbps', maxHeight: 480, bitrate: 2500000 });
|
||||
options.push({ name: '480p - 2Mbps', maxHeight: 480, bitrate: 2000001 });
|
||||
options.push({ name: '480p - 1.5Mbps', maxHeight: 480, bitrate: 1500001 });
|
||||
}
|
||||
|
||||
if (maxAllowedWidth >= 1260) {
|
||||
options.push({ name: '720p - 4Mbps', maxHeight: 720, bitrate: 4000000 });
|
||||
options.push({ name: '720p - 3Mbps', maxHeight: 720, bitrate: 3000000 });
|
||||
options.push({ name: '720p - 2Mbps', maxHeight: 720, bitrate: 2000000 });
|
||||
|
||||
// The extra 1 is because they're keyed off the bitrate value
|
||||
options.push({ name: '720p - 1.5Mbps', maxHeight: 720, bitrate: 1500000 });
|
||||
options.push({ name: '720p - 1Mbps', maxHeight: 720, bitrate: 1000001 });
|
||||
}
|
||||
|
||||
options.push({ name: '480p - 1.0Mbps', maxHeight: 480, bitrate: 1000000 });
|
||||
options.push({ name: '480p - 720kbps', maxHeight: 480, bitrate: 720000 });
|
||||
options.push({ name: '480p - 420kbps', maxHeight: 480, bitrate: 420000 });
|
||||
options.push({ name: '360p', maxHeight: 360, bitrate: 400000 });
|
||||
options.push({ name: '240p', maxHeight: 240, bitrate: 320000 });
|
||||
options.push({ name: '144p', maxHeight: 144, bitrate: 192000 });
|
||||
|
||||
var i, length, option;
|
||||
var selectedIndex = -1;
|
||||
for (i = 0, length = options.length; i < length; i++) {
|
||||
|
||||
option = options[i];
|
||||
|
||||
if (selectedIndex == -1 && option.bitrate <= bitrateSetting) {
|
||||
selectedIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedIndex == -1) {
|
||||
|
||||
selectedIndex = options.length - 1;
|
||||
}
|
||||
|
||||
options[selectedIndex].selected = true;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
self.getDeviceProfile = function (maxHeight) {
|
||||
|
||||
if (!maxHeight) {
|
||||
maxHeight = self.getVideoQualityOptions().filter(function (q) {
|
||||
maxHeight = qualityoptions.getVideoQualityOptions(bitrateSetting).filter(function (q) {
|
||||
return q.selected;
|
||||
})[0].maxHeight;
|
||||
}
|
||||
|
||||
var isVlc = AppInfo.isNativeApp && browserInfo.android;
|
||||
var bitrateSetting = AppSettings.maxStreamingBitrate();
|
||||
|
||||
var supportedFormats = getSupportedFormats();
|
||||
|
||||
|
@ -508,7 +437,9 @@
|
|||
MimeType: 'video/webm'
|
||||
});
|
||||
|
||||
return profile;
|
||||
resolve(profile);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var supportsTextTracks;
|
||||
|
@ -633,7 +564,7 @@
|
|||
var playSessionId = getParameterByName('PlaySessionId', currentSrc);
|
||||
var liveStreamId = getParameterByName('LiveStreamId', currentSrc);
|
||||
|
||||
var deviceProfile = self.getDeviceProfile();
|
||||
self.getDeviceProfile().then(function (deviceProfile) {
|
||||
|
||||
var audioStreamIndex = params.AudioStreamIndex == null ? (getParameterByName('AudioStreamIndex', currentSrc) || null) : params.AudioStreamIndex;
|
||||
if (typeof (audioStreamIndex) == 'string') {
|
||||
|
@ -664,6 +595,7 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function changeStreamToUrl(mediaRenderer, playSessionId, streamInfo) {
|
||||
|
@ -1089,6 +1021,12 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var onBitrateDetected = function() {
|
||||
self.getDeviceProfile().then(function(deviceProfile) {
|
||||
playOnDeviceProfileCreated(deviceProfile, item, startPosition, callback);
|
||||
});
|
||||
};
|
||||
|
||||
var bitrateDetectionKey = ApiClient.serverAddress();
|
||||
|
||||
if (item.MediaType == 'Video' && AppSettings.enableAutomaticBitrateDetection() && (new Date().getTime() - (self.lastBitrateDetections[bitrateDetectionKey] || 0)) > 300000) {
|
||||
|
@ -1100,15 +1038,12 @@
|
|||
self.lastBitrateDetections[bitrateDetectionKey] = new Date().getTime();
|
||||
AppSettings.maxStreamingBitrate(bitrate);
|
||||
|
||||
playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback);
|
||||
onBitrateDetected();
|
||||
|
||||
}, function () {
|
||||
|
||||
playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback);
|
||||
});
|
||||
}, onBitrateDetected);
|
||||
|
||||
} else {
|
||||
playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback);
|
||||
onBitrateDetected();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
page.querySelector('.chkEnableChromecastAc3').checked = AppSettings.enableChromecastAc3();
|
||||
page.querySelector('.chkExternalVideoPlayer').checked = AppSettings.enableExternalPlayers();
|
||||
|
||||
var bitrateOptions = MediaPlayer.getVideoQualityOptions().map(function (i) {
|
||||
require(['qualityoptions'], function (qualityoptions) {
|
||||
|
||||
var bitrateOptions = qualityoptions.getVideoQualityOptions(AppSettings.maxStreamingBitrate()).map(function (i) {
|
||||
|
||||
return '<option value="' + i.bitrate + '">' + i.name + '</option>';
|
||||
|
||||
|
@ -53,6 +55,7 @@
|
|||
$('#selectMaxChromecastBitrate', page).val(AppSettings.maxChromecastBitrate());
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
}
|
||||
|
||||
function loadPage(page) {
|
||||
|
|
|
@ -1843,6 +1843,7 @@ var AppInfo = {};
|
|||
connectionmanagerfactory: apiClientBowerPath + '/connectionmanager',
|
||||
browserdeviceprofile: embyWebComponentsBowerPath + "/browserdeviceprofile",
|
||||
browser: embyWebComponentsBowerPath + "/browser",
|
||||
qualityoptions: embyWebComponentsBowerPath + "/qualityoptions",
|
||||
connectservice: apiClientBowerPath + '/connectservice'
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue