From 965dc0b07b2122d2b0317c73e642b372fb439616 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 29 Dec 2015 12:10:21 -0500 Subject: [PATCH] use shared components for quality options --- .../emby-webcomponents/.bower.json | 8 +- .../browserdeviceprofile.js | 26 +- .../emby-webcomponents/qualityoptions.js | 81 ++ .../iron-behaviors/.bower.json | 6 +- .../iron-selector/.bower.json | 4 +- dashboard-ui/scripts/mediaplayer-video.js | 53 +- dashboard-ui/scripts/mediaplayer.js | 881 ++++++++---------- .../scripts/mypreferenceslanguages.js | 27 +- dashboard-ui/scripts/site.js | 1 + 9 files changed, 565 insertions(+), 522 deletions(-) create mode 100644 dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js diff --git a/dashboard-ui/bower_components/emby-webcomponents/.bower.json b/dashboard-ui/bower_components/emby-webcomponents/.bower.json index d62e0f8ed6..8200afb011 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/.bower.json +++ b/dashboard-ui/bower_components/emby-webcomponents/.bower.json @@ -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", diff --git a/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js b/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js index 17ab704e3d..92dcb9cda4 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js +++ b/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js @@ -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', diff --git a/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js b/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js new file mode 100644 index 0000000000..5b628053d7 --- /dev/null +++ b/dashboard-ui/bower_components/emby-webcomponents/qualityoptions.js @@ -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 + }; +}); \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-behaviors/.bower.json b/dashboard-ui/bower_components/iron-behaviors/.bower.json index db08f2170c..17f68b3351 100644 --- a/dashboard-ui/bower_components/iron-behaviors/.bower.json +++ b/dashboard-ui/bower_components/iron-behaviors/.bower.json @@ -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" } \ No newline at end of file diff --git a/dashboard-ui/bower_components/iron-selector/.bower.json b/dashboard-ui/bower_components/iron-selector/.bower.json index 52d44c1907..ebb18c5b7b 100644 --- a/dashboard-ui/bower_components/iron-selector/.bower.json +++ b/dashboard-ui/bower_components/iron-selector/.bower.json @@ -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" } \ No newline at end of file diff --git a/dashboard-ui/scripts/mediaplayer-video.js b/dashboard-ui/scripts/mediaplayer-video.js index 435c64ae54..5077d4e93b 100644 --- a/dashboard-ui/scripts/mediaplayer-video.js +++ b/dashboard-ui/scripts/mediaplayer-video.js @@ -140,41 +140,40 @@ self.showQualityFlyout = function () { - var currentSrc = self.getCurrentSrc(self.currentMediaRenderer).toLowerCase(); - var isStatic = currentSrc.indexOf('static=true') != -1; + require(['qualityoptions', 'actionsheet'], function (qualityoptions) { - var videoStream = self.currentMediaSource.MediaStreams.filter(function (stream) { - return stream.Type == "Video"; - })[0]; - var videoWidth = videoStream ? videoStream.Width : null; - var videoHeight = videoStream ? videoStream.Height : null; + var currentSrc = self.getCurrentSrc(self.currentMediaRenderer).toLowerCase(); + var isStatic = currentSrc.indexOf('static=true') != -1; - var options = self.getVideoQualityOptions(videoWidth, videoHeight); + var videoStream = self.currentMediaSource.MediaStreams.filter(function (stream) { + return stream.Type == "Video"; + })[0]; + var videoWidth = videoStream ? videoStream.Width : null; - if (isStatic) { - options[0].name = "Direct"; - } + var options = qualityoptions.getVideoQualityOptions(AppSettings.maxStreamingBitrate(), videoWidth); - var menuItems = options.map(function (o) { - - var opt = { - name: o.name, - id: o.bitrate - }; - - if (o.selected) { - opt.ironIcon = "check"; + if (isStatic) { + options[0].name = "Direct"; } - return opt; - }); + var menuItems = options.map(function (o) { - var selectedId = options.filter(function (o) { - return o.selected; - }); - selectedId = selectedId.length ? selectedId[0].bitrate : null; - require(['actionsheet'], function () { + var opt = { + name: o.name, + id: o.bitrate + }; + if (o.selected) { + opt.ironIcon = "check"; + } + + return opt; + }); + + var selectedId = options.filter(function (o) { + return o.selected; + }); + selectedId = selectedId.length ? selectedId[0].bitrate : null; ActionSheetElement.show({ items: menuItems, positionTo: $('.videoQualityButton')[0], diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 234073a530..295ac35a1a 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -36,479 +36,410 @@ return targets; }; - self.getVideoQualityOptions = function (videoWidth, videoHeight) { - - 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) { - return q.selected; - })[0].maxHeight; - } + return new Promise(function (resolve, reject) { - var isVlc = AppInfo.isNativeApp && browserInfo.android; - var bitrateSetting = AppSettings.maxStreamingBitrate(); + require(['qualityoptions'], function (qualityoptions) { - var supportedFormats = getSupportedFormats(); + var bitrateSetting = AppSettings.maxStreamingBitrate(); - var canPlayWebm = supportedFormats.indexOf('webm') != -1; - var canPlayAc3 = supportedFormats.indexOf('ac3') != -1; - var canPlayAac = supportedFormats.indexOf('aac') != -1; - var canPlayMp3 = supportedFormats.indexOf('mp3') != -1; - var canPlayMkv = supportedFormats.indexOf('mkv') != -1; + if (!maxHeight) { + maxHeight = qualityoptions.getVideoQualityOptions(bitrateSetting).filter(function (q) { + return q.selected; + })[0].maxHeight; + } - var profile = {}; + var isVlc = AppInfo.isNativeApp && browserInfo.android; - profile.MaxStreamingBitrate = bitrateSetting; - profile.MaxStaticBitrate = 8000000; - profile.MusicStreamingTranscodingBitrate = Math.min(bitrateSetting, 192000); + var supportedFormats = getSupportedFormats(); - profile.DirectPlayProfiles = []; + var canPlayWebm = supportedFormats.indexOf('webm') != -1; + var canPlayAc3 = supportedFormats.indexOf('ac3') != -1; + var canPlayAac = supportedFormats.indexOf('aac') != -1; + var canPlayMp3 = supportedFormats.indexOf('mp3') != -1; + var canPlayMkv = supportedFormats.indexOf('mkv') != -1; - if (supportedFormats.indexOf('h264') != -1) { - profile.DirectPlayProfiles.push({ - Container: 'mp4,m4v', - Type: 'Video', - VideoCodec: 'h264', - AudioCodec: 'aac' + (canPlayMp3 ? ',mp3' : '') + (canPlayAc3 ? ',ac3' : '') - }); - } + var profile = {}; - if (canPlayMkv) { - profile.DirectPlayProfiles.push({ - Container: 'mkv,mov', - Type: 'Video', - VideoCodec: 'h264', - AudioCodec: 'aac' + (canPlayMp3 ? ',mp3' : '') + (canPlayAc3 ? ',ac3' : '') - }); - } + profile.MaxStreamingBitrate = bitrateSetting; + profile.MaxStaticBitrate = 8000000; + profile.MusicStreamingTranscodingBitrate = Math.min(bitrateSetting, 192000); - var directPlayVideoContainers = AppInfo.directPlayVideoContainers; + profile.DirectPlayProfiles = []; - if (directPlayVideoContainers && directPlayVideoContainers.length) { - profile.DirectPlayProfiles.push({ - Container: directPlayVideoContainers.join(','), - Type: 'Video' - }); - } + if (supportedFormats.indexOf('h264') != -1) { + profile.DirectPlayProfiles.push({ + Container: 'mp4,m4v', + Type: 'Video', + VideoCodec: 'h264', + AudioCodec: 'aac' + (canPlayMp3 ? ',mp3' : '') + (canPlayAc3 ? ',ac3' : '') + }); + } - ['opus', 'mp3', 'aac', 'webma'].forEach(function(audioFormat){ + if (canPlayMkv) { + profile.DirectPlayProfiles.push({ + Container: 'mkv,mov', + Type: 'Video', + VideoCodec: 'h264', + AudioCodec: 'aac' + (canPlayMp3 ? ',mp3' : '') + (canPlayAc3 ? ',ac3' : '') + }); + } - if (supportedFormats.indexOf(audioFormat) != -1) { - profile.DirectPlayProfiles.push({ - Container: audioFormat == 'webma' ? 'webma,webm' : audioFormat, - Type: 'Audio' - }); - } - }); + var directPlayVideoContainers = AppInfo.directPlayVideoContainers; - var directPlayAudioContainers = AppInfo.directPlayAudioContainers; + if (directPlayVideoContainers && directPlayVideoContainers.length) { + profile.DirectPlayProfiles.push({ + Container: directPlayVideoContainers.join(','), + Type: 'Video' + }); + } - if (directPlayAudioContainers && directPlayAudioContainers.length) { - profile.DirectPlayProfiles.push({ - Container: directPlayAudioContainers.join(','), - Type: 'Audio' - }); - } + ['opus', 'mp3', 'aac', 'webma'].forEach(function (audioFormat) { - if (canPlayWebm) { - profile.DirectPlayProfiles.push({ - Container: 'webm', - Type: 'Video' - }); - } + if (supportedFormats.indexOf(audioFormat) != -1) { + profile.DirectPlayProfiles.push({ + Container: audioFormat == 'webma' ? 'webma,webm' : audioFormat, + Type: 'Audio' + }); + } + }); - profile.TranscodingProfiles = []; + var directPlayAudioContainers = AppInfo.directPlayAudioContainers; - // Can't use mkv on mobile because we have to use the native player controls and they won't be able to seek it - if (canPlayMkv && !isVlc && !browserInfo.mobile) { - profile.TranscodingProfiles.push({ - Container: 'mkv', - Type: 'Video', - AudioCodec: 'aac' + (canPlayAc3 ? ',ac3' : '') + (canPlayMp3 ? ',mp3' : ''), - VideoCodec: 'h264', - Context: 'Streaming' - }); - } + if (directPlayAudioContainers && directPlayAudioContainers.length) { + profile.DirectPlayProfiles.push({ + Container: directPlayAudioContainers.join(','), + Type: 'Audio' + }); + } - if (self.canPlayHls()) { - profile.TranscodingProfiles.push({ - Container: 'ts', - Type: 'Video', - AudioCodec: 'aac' + (canPlayAc3 ? ',ac3' : ''), - VideoCodec: 'h264', - Context: 'Streaming', - Protocol: 'hls' - }); + if (canPlayWebm) { + profile.DirectPlayProfiles.push({ + Container: 'webm', + Type: 'Video' + }); + } + + profile.TranscodingProfiles = []; + + // Can't use mkv on mobile because we have to use the native player controls and they won't be able to seek it + if (canPlayMkv && !isVlc && !browserInfo.mobile) { + profile.TranscodingProfiles.push({ + Container: 'mkv', + Type: 'Video', + AudioCodec: 'aac' + (canPlayAc3 ? ',ac3' : '') + (canPlayMp3 ? ',mp3' : ''), + VideoCodec: 'h264', + Context: 'Streaming' + }); + } + + if (self.canPlayHls()) { + profile.TranscodingProfiles.push({ + Container: 'ts', + Type: 'Video', + AudioCodec: 'aac' + (canPlayAc3 ? ',ac3' : ''), + VideoCodec: 'h264', + Context: 'Streaming', + Protocol: 'hls' + }); + + if (canPlayAac && browserInfo.safari && !AppInfo.isNativeApp) { + profile.TranscodingProfiles.push({ + Container: 'ts', + Type: 'Audio', + AudioCodec: 'aac', + Context: 'Streaming', + Protocol: 'hls' + }); + } + } + + if (canPlayWebm) { + + profile.TranscodingProfiles.push({ + Container: 'webm', + Type: 'Video', + AudioCodec: 'vorbis', + VideoCodec: 'vpx', + Context: 'Streaming', + Protocol: 'http' + }); + } - if (canPlayAac && browserInfo.safari && !AppInfo.isNativeApp) { profile.TranscodingProfiles.push({ - Container: 'ts', - Type: 'Audio', + Container: 'mp4', + Type: 'Video', AudioCodec: 'aac', + VideoCodec: 'h264', Context: 'Streaming', - Protocol: 'hls' + Protocol: 'http' }); - } - } - if (canPlayWebm) { + profile.TranscodingProfiles.push({ + Container: 'mp4', + Type: 'Video', + AudioCodec: 'aac', + VideoCodec: 'h264', + Context: 'Static', + Protocol: 'http' + }); - profile.TranscodingProfiles.push({ - Container: 'webm', - Type: 'Video', - AudioCodec: 'vorbis', - VideoCodec: 'vpx', - Context: 'Streaming', - Protocol: 'http' - }); - } + ['opus', 'mp3', 'aac'].forEach(function (audioFormat) { - profile.TranscodingProfiles.push({ - Container: 'mp4', - Type: 'Video', - AudioCodec: 'aac', - VideoCodec: 'h264', - Context: 'Streaming', - Protocol: 'http' - }); + if (supportedFormats.indexOf(audioFormat) != -1) { + profile.TranscodingProfiles.push({ + Container: audioFormat, + Type: 'Audio', + AudioCodec: audioFormat, + Context: 'Streaming', + Protocol: 'http' + }); + profile.TranscodingProfiles.push({ + Container: audioFormat, + Type: 'Audio', + AudioCodec: audioFormat, + Context: 'Static', + Protocol: 'http' + }); + } + }); - profile.TranscodingProfiles.push({ - Container: 'mp4', - Type: 'Video', - AudioCodec: 'aac', - VideoCodec: 'h264', - Context: 'Static', - Protocol: 'http' - }); + profile.ContainerProfiles = []; - ['opus', 'mp3', 'aac'].forEach(function(audioFormat){ - - if (supportedFormats.indexOf(audioFormat) != -1) { - profile.TranscodingProfiles.push({ - Container: audioFormat, - Type: 'Audio', - AudioCodec: audioFormat, - Context: 'Streaming', - Protocol: 'http' - }); - profile.TranscodingProfiles.push({ - Container: audioFormat, - Type: 'Audio', - AudioCodec: audioFormat, - Context: 'Static', - Protocol: 'http' - }); - } - }); - - profile.ContainerProfiles = []; - - profile.CodecProfiles = []; - profile.CodecProfiles.push({ - Type: 'Audio', - Conditions: [{ - Condition: 'LessThanEqual', - Property: 'AudioChannels', - Value: '2' - }] - }); - - // These don't play very well - if (isVlc) { - profile.CodecProfiles.push({ - Type: 'VideoAudio', - Codec: 'dca', - Conditions: [ - { + profile.CodecProfiles = []; + profile.CodecProfiles.push({ + Type: 'Audio', + Conditions: [{ Condition: 'LessThanEqual', Property: 'AudioChannels', - Value: 6 + Value: '2' + }] + }); + + // These don't play very well + if (isVlc) { + profile.CodecProfiles.push({ + Type: 'VideoAudio', + Codec: 'dca', + Conditions: [ + { + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: 6 + } + ] + }); + + profile.CodecProfiles.push({ + Type: 'VideoAudio', + Codec: 'aac,mp3', + Conditions: [ + { + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: '6' + } + ] + }); + + } else { + + var videoAudioChannels = browserInfo.safari ? '2' : '6'; + + profile.CodecProfiles.push({ + Type: 'VideoAudio', + Codec: 'aac', + Container: 'mkv,mov', + Conditions: [ + { + Condition: 'NotEquals', + Property: 'AudioProfile', + Value: 'HE-AAC' + }, + { + Condition: 'Equals', + Property: 'IsSecondaryAudio', + Value: 'false', + IsRequired: 'false' + }, + { + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: videoAudioChannels + } + // Disabling this is going to require us to learn why it was disabled in the first place + //, + //{ + // Condition: 'NotEquals', + // Property: 'AudioProfile', + // Value: 'LC' + //} + ] + }); + + profile.CodecProfiles.push({ + Type: 'VideoAudio', + Conditions: [ + { + Condition: 'Equals', + Property: 'IsSecondaryAudio', + Value: 'false', + IsRequired: 'false' + }, + { + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: videoAudioChannels + } + ] + }); + + } + + if (isVlc) { + profile.CodecProfiles.push({ + Type: 'Video', + Codec: 'h264', + Conditions: [ + { + Condition: 'EqualsAny', + Property: 'VideoProfile', + Value: 'high|main|baseline|constrained baseline' + }, + { + Condition: 'LessThanEqual', + Property: 'VideoLevel', + Value: '41' + }] + }); + } else { + profile.CodecProfiles.push({ + Type: 'Video', + Codec: 'h264', + Conditions: [ + { + Condition: 'NotEquals', + Property: 'IsAnamorphic', + Value: 'true', + IsRequired: false + }, + { + Condition: 'EqualsAny', + Property: 'VideoProfile', + Value: 'high|main|baseline|constrained baseline' + }, + { + Condition: 'LessThanEqual', + Property: 'VideoLevel', + Value: '41' + }, + { + Condition: 'LessThanEqual', + Property: 'Height', + Value: maxHeight + }] + }); + } + + if (!isVlc) { + profile.CodecProfiles.push({ + Type: 'Video', + Codec: 'vpx', + Conditions: [ + { + Condition: 'NotEquals', + Property: 'IsAnamorphic', + Value: 'true', + IsRequired: false + }, + { + Condition: 'LessThanEqual', + Property: 'Height', + Value: maxHeight + }] + }); + } + + // Subtitle profiles + // External vtt or burn in + profile.SubtitleProfiles = []; + if (self.supportsTextTracks()) { + + if (isVlc) { + profile.SubtitleProfiles.push({ + Format: 'srt', + Method: 'External' + }); + profile.SubtitleProfiles.push({ + Format: 'srt', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'subrip', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'ass', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'ssa', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'pgs', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'pgssub', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'dvdsub', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'vtt', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'sub', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'idx', + Method: 'Embed' + }); + profile.SubtitleProfiles.push({ + Format: 'smi', + Method: 'Embed' + }); + } else { + profile.SubtitleProfiles.push({ + Format: 'vtt', + Method: 'External' + }); } - ] + } + + profile.ResponseProfiles = []; + + profile.ResponseProfiles.push({ + Type: 'Video', + Container: 'm4v', + MimeType: 'video/mp4' + }); + + profile.ResponseProfiles.push({ + Type: 'Video', + Container: 'mov', + MimeType: 'video/webm' + }); + + resolve(profile); }); - - profile.CodecProfiles.push({ - Type: 'VideoAudio', - Codec: 'aac,mp3', - Conditions: [ - { - Condition: 'LessThanEqual', - Property: 'AudioChannels', - Value: '6' - } - ] - }); - - } else { - - var videoAudioChannels = browserInfo.safari ? '2' : '6'; - - profile.CodecProfiles.push({ - Type: 'VideoAudio', - Codec: 'aac', - Container: 'mkv,mov', - Conditions: [ - { - Condition: 'NotEquals', - Property: 'AudioProfile', - Value: 'HE-AAC' - }, - { - Condition: 'Equals', - Property: 'IsSecondaryAudio', - Value: 'false', - IsRequired: 'false' - }, - { - Condition: 'LessThanEqual', - Property: 'AudioChannels', - Value: videoAudioChannels - } - // Disabling this is going to require us to learn why it was disabled in the first place - //, - //{ - // Condition: 'NotEquals', - // Property: 'AudioProfile', - // Value: 'LC' - //} - ] - }); - - profile.CodecProfiles.push({ - Type: 'VideoAudio', - Conditions: [ - { - Condition: 'Equals', - Property: 'IsSecondaryAudio', - Value: 'false', - IsRequired: 'false' - }, - { - Condition: 'LessThanEqual', - Property: 'AudioChannels', - Value: videoAudioChannels - } - ] - }); - - } - - if (isVlc) { - profile.CodecProfiles.push({ - Type: 'Video', - Codec: 'h264', - Conditions: [ - { - Condition: 'EqualsAny', - Property: 'VideoProfile', - Value: 'high|main|baseline|constrained baseline' - }, - { - Condition: 'LessThanEqual', - Property: 'VideoLevel', - Value: '41' - }] - }); - } else { - profile.CodecProfiles.push({ - Type: 'Video', - Codec: 'h264', - Conditions: [ - { - Condition: 'NotEquals', - Property: 'IsAnamorphic', - Value: 'true', - IsRequired: false - }, - { - Condition: 'EqualsAny', - Property: 'VideoProfile', - Value: 'high|main|baseline|constrained baseline' - }, - { - Condition: 'LessThanEqual', - Property: 'VideoLevel', - Value: '41' - }, - { - Condition: 'LessThanEqual', - Property: 'Height', - Value: maxHeight - }] - }); - } - - if (!isVlc) { - profile.CodecProfiles.push({ - Type: 'Video', - Codec: 'vpx', - Conditions: [ - { - Condition: 'NotEquals', - Property: 'IsAnamorphic', - Value: 'true', - IsRequired: false - }, - { - Condition: 'LessThanEqual', - Property: 'Height', - Value: maxHeight - }] - }); - } - - // Subtitle profiles - // External vtt or burn in - profile.SubtitleProfiles = []; - if (self.supportsTextTracks()) { - - if (isVlc) { - profile.SubtitleProfiles.push({ - Format: 'srt', - Method: 'External' - }); - profile.SubtitleProfiles.push({ - Format: 'srt', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'subrip', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'ass', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'ssa', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'pgs', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'pgssub', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'dvdsub', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'vtt', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'sub', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'idx', - Method: 'Embed' - }); - profile.SubtitleProfiles.push({ - Format: 'smi', - Method: 'Embed' - }); - } else { - profile.SubtitleProfiles.push({ - Format: 'vtt', - Method: 'External' - }); - } - } - - profile.ResponseProfiles = []; - - profile.ResponseProfiles.push({ - Type: 'Video', - Container: 'm4v', - MimeType: 'video/mp4' }); - - profile.ResponseProfiles.push({ - Type: 'Video', - Container: 'mov', - MimeType: 'video/webm' - }); - - return profile; }; var supportsTextTracks; @@ -633,36 +564,37 @@ var playSessionId = getParameterByName('PlaySessionId', currentSrc); var liveStreamId = getParameterByName('LiveStreamId', currentSrc); - var deviceProfile = self.getDeviceProfile(); - - var audioStreamIndex = params.AudioStreamIndex == null ? (getParameterByName('AudioStreamIndex', currentSrc) || null) : params.AudioStreamIndex; - if (typeof (audioStreamIndex) == 'string') { - audioStreamIndex = parseInt(audioStreamIndex); - } - - var subtitleStreamIndex = params.SubtitleStreamIndex == null ? (getParameterByName('SubtitleStreamIndex', currentSrc) || null) : params.SubtitleStreamIndex; - if (typeof (subtitleStreamIndex) == 'string') { - subtitleStreamIndex = parseInt(subtitleStreamIndex); - } - - MediaController.getPlaybackInfo(self.currentItem.Id, deviceProfile, ticks, self.currentMediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).then(function (result) { - - if (validatePlaybackInfoResult(result)) { - - self.currentMediaSource = result.MediaSources[0]; - self.createStreamInfo(self.currentItem.MediaType, self.currentItem, self.currentMediaSource, ticks).then(function (streamInfo) { - - if (!streamInfo.url) { - MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream'); - self.stop(); - return; - } - - self.currentSubtitleStreamIndex = subtitleStreamIndex; - - changeStreamToUrl(mediaRenderer, playSessionId, streamInfo); - }); + self.getDeviceProfile().then(function (deviceProfile) { + + var audioStreamIndex = params.AudioStreamIndex == null ? (getParameterByName('AudioStreamIndex', currentSrc) || null) : params.AudioStreamIndex; + if (typeof (audioStreamIndex) == 'string') { + audioStreamIndex = parseInt(audioStreamIndex); } + + var subtitleStreamIndex = params.SubtitleStreamIndex == null ? (getParameterByName('SubtitleStreamIndex', currentSrc) || null) : params.SubtitleStreamIndex; + if (typeof (subtitleStreamIndex) == 'string') { + subtitleStreamIndex = parseInt(subtitleStreamIndex); + } + + MediaController.getPlaybackInfo(self.currentItem.Id, deviceProfile, ticks, self.currentMediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).then(function (result) { + + if (validatePlaybackInfoResult(result)) { + + self.currentMediaSource = result.MediaSources[0]; + self.createStreamInfo(self.currentItem.MediaType, self.currentItem, self.currentMediaSource, ticks).then(function (streamInfo) { + + if (!streamInfo.url) { + MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream'); + self.stop(); + return; + } + + self.currentSubtitleStreamIndex = subtitleStreamIndex; + + 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(); } }; diff --git a/dashboard-ui/scripts/mypreferenceslanguages.js b/dashboard-ui/scripts/mypreferenceslanguages.js index a74c54f685..aad219ad4f 100644 --- a/dashboard-ui/scripts/mypreferenceslanguages.js +++ b/dashboard-ui/scripts/mypreferenceslanguages.js @@ -34,25 +34,28 @@ page.querySelector('.chkEnableChromecastAc3').checked = AppSettings.enableChromecastAc3(); page.querySelector('.chkExternalVideoPlayer').checked = AppSettings.enableExternalPlayers(); - var bitrateOptions = MediaPlayer.getVideoQualityOptions().map(function (i) { + require(['qualityoptions'], function (qualityoptions) { - return ''; + var bitrateOptions = qualityoptions.getVideoQualityOptions(AppSettings.maxStreamingBitrate()).map(function (i) { - }).join(''); + return ''; - bitrateOptions = '' + bitrateOptions; + }).join(''); - $('#selectMaxBitrate', page).html(bitrateOptions); + bitrateOptions = '' + bitrateOptions; - if (AppSettings.enableAutomaticBitrateDetection()) { - $('#selectMaxBitrate', page).val(''); - } else { - $('#selectMaxBitrate', page).val(AppSettings.maxStreamingBitrate()); - } + $('#selectMaxBitrate', page).html(bitrateOptions); - $('#selectMaxChromecastBitrate', page).val(AppSettings.maxChromecastBitrate()); + if (AppSettings.enableAutomaticBitrateDetection()) { + $('#selectMaxBitrate', page).val(''); + } else { + $('#selectMaxBitrate', page).val(AppSettings.maxStreamingBitrate()); + } - Dashboard.hideLoadingMsg(); + $('#selectMaxChromecastBitrate', page).val(AppSettings.maxChromecastBitrate()); + + Dashboard.hideLoadingMsg(); + }); } function loadPage(page) { diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 1b1435dbed..1c07857881 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1843,6 +1843,7 @@ var AppInfo = {}; connectionmanagerfactory: apiClientBowerPath + '/connectionmanager', browserdeviceprofile: embyWebComponentsBowerPath + "/browserdeviceprofile", browser: embyWebComponentsBowerPath + "/browser", + qualityoptions: embyWebComponentsBowerPath + "/qualityoptions", connectservice: apiClientBowerPath + '/connectservice' };