mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Extract URL loader component
This commit is contained in:
parent
d7ba6d8c60
commit
eb8025791b
3 changed files with 37 additions and 21 deletions
|
|
@ -1,31 +1,15 @@
|
|||
import { h } from 'preact'
|
||||
|
||||
import { useState, useEffect } from 'preact/hooks'
|
||||
import { prepareVM } from '~/src/common/if'
|
||||
|
||||
const INITIAL_STATUS = {
|
||||
level: 'loading',
|
||||
details: 'Loading...'
|
||||
}
|
||||
import UrlPlayer from '~/src/components/player/UrlPlayer'
|
||||
|
||||
export default function ({setTheme, theme, encodedUrl}) {
|
||||
const [url] = useState(decodeURIComponent(encodedUrl))
|
||||
const [status, setStatus] = useState(INITIAL_STATUS)
|
||||
|
||||
const [vm, setVM] = useState(null)
|
||||
|
||||
useEffect(() => setTheme(theme), [theme])
|
||||
useEffect(prepareVM({
|
||||
url,
|
||||
setStatus,
|
||||
setVM
|
||||
}), [url])
|
||||
|
||||
useEffect(() => {
|
||||
if (vm) console.log('success', vm)
|
||||
}, [vm])
|
||||
return (
|
||||
<main>
|
||||
{status.details}
|
||||
<UrlPlayer url={url} />
|
||||
</main>)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue