diff --git a/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js b/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js index 9674fca848..d86a58869c 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js +++ b/dashboard-ui/bower_components/emby-webcomponents/browserdeviceprofile.js @@ -269,7 +269,7 @@ define(['browser'], function (browser) { } var mp3Added = false; - if (canPlayMkv || canPlayTs) { + if ((canPlayMkv && options.enableMkvProgressive !== false) || (canPlayTs && options.enableMkvProgressive !== false)) { if (supportsMp3VideoAudio) { mp3Added = true; videoAudioCodecs.push('mp3'); @@ -421,7 +421,8 @@ define(['browser'], function (browser) { AudioCodec: hlsVideoAudioCodecs.join(','), VideoCodec: 'h264', Context: 'Streaming', - Protocol: 'hls' + Protocol: 'hls', + MaxAudioChannels: physicalAudioChannels.toString() }); } diff --git a/dashboard-ui/scripts/htmlmediarenderer.js b/dashboard-ui/scripts/htmlmediarenderer.js index cdc4d4ea3f..754da83152 100644 --- a/dashboard-ui/scripts/htmlmediarenderer.js +++ b/dashboard-ui/scripts/htmlmediarenderer.js @@ -170,7 +170,7 @@ return elem; } - function enableHlsPlayer(src) { + function enableHlsPlayer(src, item, mediaSource) { if (src) { if (src.indexOf('.m3u8') == -1) { @@ -178,7 +178,25 @@ } } - return MediaPlayer.canPlayHls() && !MediaPlayer.canPlayNativeHls(); + if (MediaPlayer.canPlayHls()) { + + if (window.MediaSource == null) { + return false; + } + + if (MediaPlayer.canPlayNativeHls() && mediaSource.RunTimeTicks) { + return false; + } + + // For now don't do this in edge because we lose some native audio support + if (browser.edge) { + return false; + } + + return true; + } + + return false; } function getCrossOriginValue(mediaSource) { @@ -384,17 +402,19 @@ } subtitleTrackIndexToSetOnPlaying = currentTrackIndex; - if (enableHlsPlayer(val)) { + if (enableHlsPlayer(val, item, mediaSource)) { setTracks(elem, tracks); - var hls = new Hls(); - hls.loadSource(val); - hls.attachMedia(elem); - hls.on(Hls.Events.MANIFEST_PARSED, function () { - elem.play(); + requireHlsPlayer(function () { + var hls = new Hls(); + hls.loadSource(val); + hls.attachMedia(elem); + hls.on(Hls.Events.MANIFEST_PARSED, function () { + elem.play(); + }); + hlsPlayer = hls; }); - hlsPlayer = hls; } else { @@ -880,16 +900,7 @@ self.init = function () { - return new Promise(function (resolve, reject) { - - if (options.type == 'video' && enableHlsPlayer()) { - - requireHlsPlayer(resolve); - - } else { - resolve(); - } - }); + return Promise.resolve(); }; if (options.type == 'audio') { diff --git a/dashboard-ui/scripts/mediaplayer-video.js b/dashboard-ui/scripts/mediaplayer-video.js index 68dca771ea..dec583b6ad 100644 --- a/dashboard-ui/scripts/mediaplayer-video.js +++ b/dashboard-ui/scripts/mediaplayer-video.js @@ -1,4 +1,4 @@ -define(['appSettings', 'datetime', 'mediaInfo', 'scrollStyles', 'paper-icon-button-light'], function (appSettings, datetime, mediaInfo) { +define(['appSettings', 'datetime', 'mediaInfo', 'browser', 'scrollStyles', 'paper-icon-button-light'], function (appSettings, datetime, mediaInfo, browser) { function createVideoPlayer(self) { @@ -710,7 +710,7 @@ html += '
'; html += ''; - var hiddenOnIdleClass = AppInfo.isNativeApp && browserInfo.android ? 'hiddenOnIdle hide' : 'hiddenOnIdle'; + var hiddenOnIdleClass = AppInfo.isNativeApp && browser.android ? 'hiddenOnIdle hide' : 'hiddenOnIdle'; html += '
'; html += ''; @@ -984,7 +984,7 @@ self.playVideo = function (item, mediaSource, startPosition, callback) { - if (browserInfo.msie) { + if (browser.msie) { if (!window.MediaSource || !mediaSource.RunTimeTicks) { alert('Playback of this content is not supported in Internet Explorer. For a better experience, please try a modern browser such as Google Chrome, Firefox, Opera, or Microsoft Edge.'); @@ -998,15 +998,20 @@ self.createStreamInfo('Video', item, mediaSource, startPosition).then(function (streamInfo) { + var onReadyToPlay = function () { + self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback); + }; + var isHls = streamInfo.url.toLowerCase().indexOf('.m3u8') != -1; // Huge hack alert. Safari doesn't seem to like if the segments aren't available right away when playback starts // This will start the transcoding process before actually feeding the video url into the player // Edit: Also seeing stalls from hls.js - if (!mediaSource.RunTimeTicks && isHls && !browserInfo.edge) { + if (!mediaSource.RunTimeTicks && isHls && !browser.edge) { + + var hlsPlaylistUrl = streamInfo.url.replace('master.m3u8', 'live.m3u8'); Dashboard.showLoadingMsg(); - var hlsPlaylistUrl = streamInfo.url.replace('master.m3u8', 'live.m3u8'); ApiClient.ajax({ type: 'GET', @@ -1016,17 +1021,14 @@ Dashboard.hideLoadingMsg(); streamInfo.url = hlsPlaylistUrl; - // add a delay to continue building up the buffer. without this we see failures in safari mobile - setTimeout(function () { - self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback); - }, 2000); + onReadyToPlay(); }, function () { Dashboard.hideLoadingMsg(); }); } else { - self.playVideoInternal(item, mediaSource, startPosition, streamInfo, callback); + onReadyToPlay(); } }); }); @@ -1064,7 +1066,7 @@ elem.classList.remove('hide'); - if (!browserInfo.animate || browserInfo.slow) { + if (!browser.animate || browser.slow) { return; } @@ -1262,7 +1264,7 @@ function onClick() { - if (!browserInfo.mobile) { + if (!browser.mobile) { if (this.paused()) { self.unpause(); } else { @@ -1272,7 +1274,7 @@ } function onDoubleClick() { - if (!browserInfo.mobile) { + if (!browser.mobile) { self.toggleFullscreen(); } }