Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/dialogs/more-info/controls/more-info-camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ class MoreInfoCamera extends UpdatingElement {
videoEl.muted = true;

// tslint:disable-next-line
let Hls: HLSModule | undefined;

let hlsSupported =
videoEl.canPlayType("application/vnd.apple.mpegurl") !== "";
const Hls = ((await import(/* webpackChunkName: "hls.js" */ "hls.js")) as any)
.default as HLSModule;
let hlsSupported = Hls.isSupported();

if (!hlsSupported) {
Hls = ((await import(/* webpackChunkName: "hls.js" */ "hls.js")) as any)
.default as HLSModule;
hlsSupported = Hls.isSupported();
hlsSupported =
videoEl.canPlayType("application/vnd.apple.mpegurl") !== "";
}

if (hlsSupported) {
Expand All @@ -76,7 +74,7 @@ class MoreInfoCamera extends UpdatingElement {
this.stateObj.entity_id
);

if (Hls) {
if (Hls.isSupported()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird. Does hls better check for supported than native? We can check the return type of can play too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So HLS.js just have to check if MediaSourceExtension is supported, which is an easy check on the window. I have no clue why canPlayType returns an empty string, maybe, or probably. All 3 of them sound pretty uncertain. All the demos I’ve looked at use HLS.js first and fallback to canPlayType, then unsupported.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._renderHLSPolyfill(videoEl, Hls, url);
} else {
this._renderHLSNative(videoEl, url);
Expand Down