forked from muxinc/elements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmux-player.tsx
More file actions
87 lines (83 loc) · 2.54 KB
/
mux-player.tsx
File metadata and controls
87 lines (83 loc) · 2.54 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// @ts-nocheck
import Link from "next/link";
import Head from "next/head";
import "@mux/mux-player";
import { useState } from "react";
const INITIAL_DEBUG = false;
const INITIAL_MUTED = false;
const INITIAL_AUTOPLAY = false;
const INITIAL_PLAYBACK_ID = "g65IqSFtWdpGR100c2W8VUHrfIVWTNRen";
function MuxPlayerWCPage() {
// const mediaElRef = useRef(null);
const [playbackId, setPlaybackId] = useState(INITIAL_PLAYBACK_ID);
const [muted, setMuted] = useState(INITIAL_MUTED);
const [debug, setDebug] = useState(INITIAL_DEBUG);
const [autoplay, setAutoplay] = useState(INITIAL_AUTOPLAY);
const debugObj = debug ? { debug: "" } : {};
const mutedObj = muted ? { muted: "" } : {};
const autoplayObj = autoplay ? { autoplay } : {};
return (
<>
<Head>
<title><mux-player> Demo</title>
</Head>
<div>
<mux-player
// style={{ aspectRatio: "16 / 9" }}
playback-id={playbackId}
forward-seek-offset={10}
backward-seek-offset={10}
//prefer-lower-resolution={false}
cap-default-resolution={550}
// onPlayerReady={() => console.log("ready!")}
{...debugObj}
{...mutedObj}
{...autoplayObj}
// stream-type="live"
// primary-color="#ec407a"
// secondary-color="#64b5f6"
// tertiary-color="#b4004e"
// startTime={12}
></mux-player>
</div>
<div className="options">
<div>
<label htmlFor="autoplay-control">Muted Autoplay</label>
<input
id="autoplay-control"
type="checkbox"
onChange={() => setAutoplay(!autoplay ? "muted" : false)}
checked={autoplay}
/>
</div>
<div>
<label htmlFor="muted-control">Muted</label>
<input
id="muted-control"
type="checkbox"
onChange={() => setMuted(!muted)}
checked={muted}
/>
</div>
<div>
<label htmlFor="debug-control">Debug</label>
<input
id="debug-control"
type="checkbox"
onChange={() => setDebug(!debug)}
checked={debug}
/>
</div>
<div>
<label htmlFor="playback-id-control">Playback Id</label>
<input
id="playback-id-control"
onBlur={({ currentTarget }) => setPlaybackId(currentTarget.value)}
defaultValue={playbackId}
/>
</div>
</div>
</>
);
}
export default MuxPlayerWCPage;