mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 21:06:15 -08:00
27 lines
661 B
JavaScript
27 lines
661 B
JavaScript
// eslint-disable-next-line no-unused-vars
|
|
import React, { useEffect, useRef } from 'react';
|
|
import Artplayer from 'artplayer';
|
|
|
|
export default function ({ 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>;
|
|
}
|