feat: update project structure and add React template with Artplayer integration

This commit is contained in:
Harvey Zack committed 2025-08-17 14:55:06 +08:00
1 parent 4b55b97e9e
commit 0eed9c114b
12 files changed
+183 -2

No files matched your search

@@ -0,0 +1,37 @@
import Artplayer from 'artplayer'
import { useEffect, useRef } from 'react'
// test i18n
import fr from 'artplayer/i18n/fr'
import id from 'artplayer/i18n/id'
// test plugins
import artplayerPluginDanmuku from '../../../artplayer-plugin-danmuku'
import artplayerPluginDocumentPip from '../../../artplayer-plugin-document-pip'
export default function Player({ option, getInstance, ...rest }) {
const $container = useRef()
useEffect(() => {
const art = new Artplayer({
...option,
container: $container.current,
i18n: { id, fr },
lang: 'fr',
plugins: [
artplayerPluginDocumentPip(),
artplayerPluginDanmuku({
danmuku: 'https://artplayer.org/assets/sample/danmuku.xml',
}),
],
})
if (typeof getInstance === 'function') {
getInstance(art)
}
return () => art.destroy(false)
}, [option, getInstance])
return <div ref={$container} {...rest}></div>
}