mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 13:21:20 -08:00
artplayer@4.3.20
This commit is contained in:
1 parent
f74a2633b3
commit
d73e1efaf1
5 files changed
+34
-29
No files matched your search
@@ -1,25 +1,28 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import Artplayer from "artplayer";
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import Artplayer from 'artplayer';
|
||||
|
||||
export default function ArtplayerReact({ option, getInstance, ...rest }) {
|
||||
const artRef = useRef();
|
||||
export default function Player({ option, getInstance, ...rest }) {
|
||||
const artRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
const art = new Artplayer({
|
||||
...option,
|
||||
container: artRef.current,
|
||||
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 React.createElement('div', {
|
||||
ref: artRef,
|
||||
...rest,
|
||||
});
|
||||
|
||||
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