mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 02:51:20 -08:00
add artplayer-template
This commit is contained in:
1 parent
8fa763b9c7
commit
703f881019
59 files changed
+1408
-1
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import Artplayer from "artplayer";
|
||||
|
||||
export default function ArtplayerReact({ option, getInstance, ...rest }) {
|
||||
const artRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
const art = new Artplayer({
|
||||
...option,
|
||||
container: artRef.current,
|
||||
});
|
||||
|
||||
if (getInstance && typeof getInstance === "function") {
|
||||
getInstance(art);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (art && art.destroy) {
|
||||
art.destroy(false);
|
||||
}
|
||||
};
|
||||
}, [option, getInstance]);
|
||||
|
||||
return <div ref={artRef} {...rest}></div>;
|
||||
}
|
||||
Reference in new issue
Block a user