diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4e5e14b8738..f52678066fd 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -93,6 +93,7 @@ - [Connor Smith](https://github.com/ConnorS1110) - [iFraan](https://github.com/iFraan) - [Ali](https://github.com/bu3alwa) +- [jmerdich](https://github.com/jmerdich) ## Emby Contributors diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 72fa188c422..8a4885c36f5 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -117,6 +117,13 @@ function normalizeName(t) { return t.toLowerCase().replace(' ', ''); } +function addOrReplaceUrlParam(url, key, value) { + // eslint-disable-next-line compat/compat + const newurl = new URL(url, window.location); + newurl.searchParams.set(key, value); + return newurl.href; +} + function getItemsForPlayback(serverId, query) { const apiClient = ServerConnections.getApiClient(serverId); @@ -2460,12 +2467,28 @@ class PlaybackManager { if (streamType == 'Subtitle') { if (isSecondarySubtitle) { mediaSource.DefaultSecondarySubtitleStreamIndex = bestStreamIndex; + // Secondary subtitles are client side only, update this if it ever gets transcoding support. } else { mediaSource.DefaultSubtitleStreamIndex = bestStreamIndex; + const isHardcodedSubtitle = mediaSource.MediaStreams[bestStreamIndex].DeliveryMethod === 'Transcode'; + if (mediaSource.TranscodingUrl) { + mediaSource.TranscodingUrl = addOrReplaceUrlParam( + mediaSource.TranscodingUrl, + 'SubtitleStreamIndex', + isHardcodedSubtitle ? mediaSource.DefaultSubtitleStreamIndex.toString() : '-1' + ); + } } } if (streamType == 'Audio') { mediaSource.DefaultAudioStreamIndex = bestStreamIndex; + if (mediaSource.TranscodingUrl) { + mediaSource.TranscodingUrl = addOrReplaceUrlParam( + mediaSource.TranscodingUrl, + 'AudioStreamIndex', + mediaSource.DefaultAudioStreamIndex.toString() + ); + } } } else { console.debug(`AutoSet ${streamType} - Threshold not met. Using default.`);