diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-04-01 18:25:27 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-04-01 18:25:27 -0400 |
| commit | e9e7ec80af0d2cae67c9dcf2cef64ca54a731046 (patch) | |
| tree | c871c9ffd49b1884c6af234f584eaf8922d377a2 /src/frontend/components | |
| parent | 15d48d4e910ec30746233599c3a577e8c3be0581 (diff) | |
| download | xesite-e9e7ec80af0d2cae67c9dcf2cef64ca54a731046.tar.xz xesite-e9e7ec80af0d2cae67c9dcf2cef64ca54a731046.zip | |
move video component to a dynamic Xeact component
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'src/frontend/components')
| -rw-r--r-- | src/frontend/components/Video.tsx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/frontend/components/Video.tsx b/src/frontend/components/Video.tsx new file mode 100644 index 0000000..812e6bd --- /dev/null +++ b/src/frontend/components/Video.tsx @@ -0,0 +1,40 @@ +// @jsxImportSource xeact +// @jsxRuntime automatic + +import Hls from "@hls.js"; + +export interface VideoProps { + path: string; +} + +export default function Video({ path }: VideoProps) { + const streamURL = + `https://cdn.xeiaso.net/file/christine-static/${path}/index.m3u8`; + const video = ( + <video style="width:100%" controls> + <source src={streamURL} type="application/vnd.apple.mpegurl" /> + <source + src="https://cdn.xeiaso.net/file/christine-static/blog/HLSBROKE.mp4" + type="video/mp4" + /> + </video> + ); + + if (Hls.isSupported()) { + const hls = new Hls(); + hls.on(Hls.Events.MEDIA_ATTACHED, () => { + console.log("video and hls.js are now bound together !"); + }); + hls.on(Hls.Events.MANIFEST_PARSED, (event, data) => { + console.log( + "manifest loaded, found " + data.levels.length + " quality level", + ); + }); + hls.loadSource(streamURL); + hls.attachMedia(video); + } else if (video.canPlayType("application/vnd.apple.mpegurl")) { + video.src = streamURL; + } + + return video; +} |
