Skip to content

Commit

Permalink
add support for EXT-X-PRELOAD-HINT in hls.js (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
lastcanal authored Sep 17, 2024
1 parent 9c29bf7 commit f7062e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions assets/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Socket } from "phoenix";
import { LiveSocket, type ViewHook } from "phoenix_live_view";
import topbar from "../vendor/topbar";
import { VidstackPlayer, VidstackPlayerLayout } from "vidstack/global/player";
import { isHLSProvider } from "vidstack";
import HLS from "@algora/hls.js";

// TODO: add eslint & biome
// TODO: enable strict mode
Expand Down Expand Up @@ -229,6 +231,16 @@ const Hooks = {
this.player.streamType = opts.is_live ? "ll-live:dvr" : "on-demand";
this.player.src = opts.url;

this.player.addEventListener("provider-change", (event) => {
const provider = event.detail;
if (isHLSProvider(provider)) {
provider.library = HLS;
provider.config = {
targetlatency: 6, // one segment
};
}
});

setMediaSession();

if (backdrop) {
Expand Down
1 change: 1 addition & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@types/phoenix_live_view": "^0.18.4"
},
"dependencies": {
"@algora/hls.js": "1.0.0",
"vidstack": "^1.12.9"
}
}
7 changes: 7 additions & 0 deletions assets/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7062e6

Please sign in to comment.