stream/app.js

39 lines
984 B
JavaScript
Raw Normal View History

2021-03-05 12:17:51 +00:00
import { h } from 'preact'
import axios from 'axios'
// eslint-disable-next-line import/no-extraneous-dependencies
import 'regenerator-runtime/runtime'
import { useEffect, useState } from 'preact/hooks'
import Video from './src/components/Video'
import config from './src/data/conf.json'
import Info from './src/components/Info'
2021-03-05 12:17:51 +00:00
export default () => {
const [isPlaying, setIsPlaying] = useState(false)
const [videoUrl, setVideoUrl] = useState(null)
useEffect(() => {
const getData = async () => {
const { data } = await axios.get(
`${config.peertube_root}/api/v1/videos/${config.next_stream.peertube_id}`
)
console.log(data)
const src = `${config.peertube_root}${data.embedPath}`
console.log('src', src)
setVideoUrl(src)
}
getData()
}, [])
return (
<div>
{videoUrl ? (
2021-03-05 12:17:51 +00:00
<Video playing={isPlaying} setPlaying={setIsPlaying} src={videoUrl} />
) : (
<Info />
2021-03-05 12:17:51 +00:00
)}
</div>
)
}