mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
34 lines
710 B
JavaScript
34 lines
710 B
JavaScript
import React from 'react'
|
|
import Aplayer from 'aplayer'
|
|
import BLOG from '@/blog.config'
|
|
|
|
const Player = () => {
|
|
const [player, setPlayer] = React.useState()
|
|
const ref = React.useRef(null)
|
|
|
|
React.useEffect(() => {
|
|
if (BLOG.MUSIC_PLAYER) {
|
|
setPlayer(new Aplayer({
|
|
container: ref.current,
|
|
fixed: true,
|
|
order: BLOG.MUSIC_PLAYER_ORDER,
|
|
autoplay: BLOG.MUSIC_PLAYER_AUTO_PLAY,
|
|
audio: BLOG.MUSIC_PLAYER_AUDIO_LIST
|
|
}))
|
|
}
|
|
return () => {
|
|
setPlayer(undefined)
|
|
}
|
|
}, [])
|
|
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
data-player={player}
|
|
className={BLOG.MUSIC_PLAYER_VISIBLE ? 'visible' : 'invisible'}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default Player
|