File size: 915 Bytes
6215321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

import React, { useEffect, useRef } from 'react';

export function BasicVideo({
  className = "",
  src,
  playbackSpeed = 1.0,
  playsInline = true,
  muted = true,
  autoPlay = true,
  loop = true,
}: {
  className?: string
  src?: string
  playbackSpeed?: number
  playsInline?: boolean
  muted?: boolean
  autoPlay?: boolean
  loop?: boolean
}) {
  const videoRef = useRef<HTMLVideoElement>(null)

  // Setup and handle changing playback rate and video source
  useEffect(() => {
    if (videoRef.current) {
      videoRef.current.playbackRate = playbackSpeed;
    }
  }, [videoRef.current, playbackSpeed]);


  // Handle UI case for empty playlists
  if (!src || typeof src !== "string") {
    return <></>
  }

  return (
    <video
      ref={videoRef}
      className={className}
      playsInline={playsInline}
      muted={muted}
      autoPlay={autoPlay}
      loop={loop}
      src={src}
    />
  );
};