Skip to content

Commit

Permalink
Fix HLS detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylyzo committed Aug 31, 2023
1 parent 5bc55f7 commit e2e31e7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugins/htmlVideoPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ function tryRemoveElement(elem) {
}
}

function enableNativeTrackSupport(currentSrc, track) {
function enableNativeTrackSupport(mediaSource, track) {
if (track?.DeliveryMethod === 'Embed') {
return true;
}

if (browser.firefox && (currentSrc || '').toLowerCase().includes('.m3u8')) {
if (browser.firefox && (mediaSource?.TranscodingSubProtocol || mediaSource?.Container) === 'hls') {
return false;
}

Expand Down Expand Up @@ -341,11 +341,11 @@ export class HtmlVideoPlayer {
* @private
*/
updateVideoUrl(streamInfo) {
const isHls = streamInfo.url.toLowerCase().includes('.m3u8');

const mediaSource = streamInfo.mediaSource;
const item = streamInfo.item;

const isHls = (mediaSource?.TranscodingSubProtocol || mediaSource?.Container) === 'hls';

// 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
Expand Down Expand Up @@ -513,7 +513,7 @@ export class HtmlVideoPlayer {
elem.crossOrigin = crossOrigin;
}

if (enableHlsJsPlayer(options.mediaSource.RunTimeTicks, 'Video') && val.includes('.m3u8')) {
if (enableHlsJsPlayer(options.mediaSource.RunTimeTicks, 'Video') && (options.mediaSource.TranscodingSubProtocol || options.mediaSource.Container) === 'hls') {
return this.setSrcWithHlsJs(elem, options, val);
} else if (options.playMethod !== 'Transcode' && options.mediaSource.Container === 'flv') {
return this.setSrcWithFlvJs(elem, options, val);
Expand Down Expand Up @@ -1561,7 +1561,7 @@ export class HtmlVideoPlayer {
})[0];

this.setTrackForDisplay(this.#mediaElement, track, targetTextTrackIndex);
if (enableNativeTrackSupport(this.#currentSrc, track)) {
if (enableNativeTrackSupport(this._currentPlayOptions?.mediaSource, track)) {
if (streamIndex !== -1) {
this.setCueAppearance();
}
Expand Down

0 comments on commit e2e31e7

Please sign in to comment.