Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'muxinc:master' into reexport-hls-library
Browse files Browse the repository at this point in the history
  • Loading branch information
evoactivity committed Jul 21, 2023
2 parents 4c15d2a + da8ab55 commit eaf44f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
32 changes: 32 additions & 0 deletions hls-video-element.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { CustomVideoElement } from 'custom-media-element';
import Hls from 'hls.js';

declare class HLSVideoElement extends CustomVideoElement {
/**
* The current instance of the HLS.js library.
*
* @example
* ```js
* const video = document.querySelector('hls-video');
* video.api.on(Hls.Events.MANIFEST_PARSED, () => {});
* ```
*/
api: Hls | null;

/**
* Fires when attributes are changed on the custom element.
*/
attributeChangedCallback(attrName: string, oldValue: any, newValue: any): void;

/**
* Loads the HLS.js instance and attach it to the video element.
*/
load(): Promise<void>;

/**
* Unloads the HLS.js instance and detaches it from the video element.
*/
#destroy(): void;
}

export default HLSVideoElement;
7 changes: 4 additions & 3 deletions hls-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class HLSVideoElement extends CustomVideoElement {
return;
}

// Wait 1 tick to allow other attributes to be set.
await Promise.resolve();


if (Hls.isSupported()) {

Expand All @@ -38,8 +37,10 @@ class HLSVideoElement extends CustomVideoElement {
liveDurationInfinity: true
});

// Set up preload
// Wait 1 tick to allow other attributes to be set.
await Promise.resolve();

// Set up preload
switch (this.nativeEl.preload) {
case 'none': {
// when preload is none, load the source on first play
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Custom element (web component) for playing video using the HTTP Live Streaming (HLS) format. Uses HLS.js.",
"type": "module",
"main": "hls-video-element.js",
"types": "hls-video-element.d.ts",
"files": [],
"scripts": {
"lint": "npx eslint *.js -c ./node_modules/wet-run/.eslintrc.json",
Expand Down

0 comments on commit eaf44f6

Please sign in to comment.