diff --git a/src/VideoPlayer.jsx b/src/VideoPlayer.jsx new file mode 100644 index 0000000..05c3dd7 --- /dev/null +++ b/src/VideoPlayer.jsx @@ -0,0 +1,43 @@ +import { h, render, Component } from "preact"; +//import React from "react"; +import Hls from "hls.js"; +import PortfolioVideo from "../static/video/index.m3u8"; +export default class VideoPlayer extends Component { + state = {}; + // componentDidUpdate() { + componentDidMount() { + const video = this.player; + const url = PortfolioVideo; //"https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"; + if (Hls.isSupported()) { + const hls = new Hls(); + + hls.loadSource(url); + hls.attachMedia(video); + hls.on(Hls.Events.MANIFEST_PARSED, function () { + video.play(); + }); + } else if (video.canPlayType("application/vnd.apple.mpegurl")) { + video.src = url; + video.addEventListener("loadedmetadata", function () { + video.play(); + }); + } + } + render() { + return ( +