diff options
author | 2021-09-12 23:11:25 +0200 | |
---|---|---|
committer | 2021-09-12 23:11:25 +0200 | |
commit | 16dab011c575eaf96630cab406ec2d8086403d0b (patch) | |
tree | af53af45b8cb52317cef3d4d59216b1c58d8d8ff /apps/Player/components/Video.js | |
parent | d79f4c0bf3dae76eaae0d36469f5b279272d6944 (diff) | |
download | my_apps-16dab011c575eaf96630cab406ec2d8086403d0b.tar.gz my_apps-16dab011c575eaf96630cab406ec2d8086403d0b.tar.bz2 my_apps-16dab011c575eaf96630cab406ec2d8086403d0b.zip |
added youtube & player apps
Diffstat (limited to 'apps/Player/components/Video.js')
-rw-r--r-- | apps/Player/components/Video.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/Player/components/Video.js b/apps/Player/components/Video.js new file mode 100644 index 0000000..7152967 --- /dev/null +++ b/apps/Player/components/Video.js @@ -0,0 +1,32 @@ +import { useRef } from 'react' +import Splash from 'components/Splash' + +const Video = ({ playlist, current, setCurrent }) => { + if (!playlist) return null + + const videoEl = useRef() + const sources = playlist[current]?.sources + + const handleEnd = () => { + setCurrent(current === playlist.length - 1 ? null : current + 1) + } + + return ( + sources + ? ( + <video onEnded={handleEnd} ref={videoEl} key={playlist[current]?.id} controls autoPlay> + { + sources.map(s => ( + <source src={s.url} type={s.mimeType} key={s.url} /> + )) + } + Your browser does not support the video tag. + </video> + ) + : ( + <Splash /> + ) + ) +} + +export default Video |