-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathaudio.tsx
47 lines (44 loc) · 1.14 KB
/
audio.tsx
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 { CSSProperties } from "react";
import { lazy, Ref } from "react";
import type {default as ReactPlayerType} from "react-player";
import styled from "styled-components";
const ReactPlayer = lazy(() => import("react-player"));
const Audio = styled(ReactPlayer)`
height: 32px !important;
`;
export function TacoAudio(props: {
url: string;
onPlay?: () => void;
onPause?: () => void;
onEnded?: () => void;
className?: string;
style?: CSSProperties;
audioRef?: Ref<ReactPlayerType>;
autoPlay?: boolean;
loop?: boolean;
}) {
const { url, onPlay, onPause, onEnded, className, style, autoPlay, loop } = props;
return (
<Audio
config={{
file: {
attributes: {
controlsList: "nofullscreen nodownload noremoteplayback noplaybackrate",
},
forceAudio: true,
},
}}
ref={props.audioRef}
draggable={false}
loop={loop}
controls
className={className}
style={style}
url={url}
playing={autoPlay}
onPlay={() => onPlay && onPlay()}
onPause={() => onPause && onPause()}
onEnded={() => onEnded && onEnded()}
/>
);
}