diff options
| author | Factiven <[email protected]> | 2023-04-14 00:14:12 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-04-14 00:14:12 +0700 |
| commit | 70fda74d27d9b55c9030932794daa25c1e6cf50d (patch) | |
| tree | 0c1f639be4e8ec1b960ba642b8e99c1485e83b1a /pages/lib/Artplayer.js | |
| parent | Update 5th (diff) | |
| download | moopa-70fda74d27d9b55c9030932794daa25c1e6cf50d.tar.xz moopa-70fda74d27d9b55c9030932794daa25c1e6cf50d.zip | |
Update 6th
Diffstat (limited to 'pages/lib/Artplayer.js')
| -rw-r--r-- | pages/lib/Artplayer.js | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/pages/lib/Artplayer.js b/pages/lib/Artplayer.js deleted file mode 100644 index 49806ed..0000000 --- a/pages/lib/Artplayer.js +++ /dev/null @@ -1,54 +0,0 @@ -import { useEffect, useRef } from "react"; -import Artplayer from "artplayer"; -import Hls from "hls.js"; - -export default function Player({ option, getInstance, ...rest }) { - const artRef = useRef(); - function playM3u8(video, url, art) { - if (Hls.isSupported()) { - const hls = new Hls(); - hls.loadSource(url); - hls.attachMedia(video); - - // optional - art.hls = hls; - art.once("url", () => hls.destroy()); - art.once("destroy", () => hls.destroy()); - } else if (video.canPlayType("application/vnd.apple.mpegurl")) { - video.src = url; - } else { - art.notice.show = "Unsupported playback format: m3u8"; - } - } - - useEffect(() => { - const art = new Artplayer({ - ...option, - container: artRef.current, - customType: { - m3u8: playM3u8, - }, - fullscreen: true, - fullscreenWeb: true, - hotkey: true, - lock: true, - autoOrientation: true, - theme: "#f97316", - icons: { - state: "</>", - }, - }); - - if (getInstance && typeof getInstance === "function") { - getInstance(art); - } - - return () => { - if (art && art.destroy) { - art.destroy(false); - } - }; - }, []); - - return <div ref={artRef} {...rest}></div>; -} |