Live video on the AT Protocol
1import { VideoView } from "expo-video";
2import { PlaceStreamDefs } from "streamplace";
3
4export enum IngestMediaSource {
5 USER = "user",
6 DISPLAY = "display",
7}
8
9// common types shared by players and controls and stuff
10export type PlayerProps = {
11 name: string;
12 src: string;
13 muted: boolean;
14 volume: number;
15 fullscreen: boolean;
16 forceProtocol?: string;
17 showControls: boolean;
18 telemetry: boolean;
19 setMuted: (isMuted: boolean) => void;
20 setVolume: (volume: number) => void;
21 setFullscreen: (isFullscreen: boolean) => void;
22 userInteraction: () => void;
23 playerEvent: (
24 time: string,
25 eventType: string,
26 meta: { [key: string]: any },
27 ) => void;
28 playerId: string;
29 status: PlayerStatus;
30 setStatus: (status: PlayerStatus) => void;
31 playTime: number;
32 setPlayTime: (playTime: number) => void;
33 ingest?: boolean;
34 ingestMediaSource?: IngestMediaSource;
35 ingestStreamKey?: string;
36 ingestAutoStart?: boolean;
37 avSyncTest?: boolean;
38 offline: boolean;
39 renditions: PlaceStreamDefs.Rendition[];
40 selectedRendition: string;
41 muteWasForced: boolean;
42 setMuteWasForced: (muteWasForced: boolean) => void;
43 embedded: boolean;
44 videoRef:
45 | React.MutableRefObject<HTMLVideoElement | null>
46 | ((instance: HTMLVideoElement | null) => void)
47 | undefined;
48
49 setPlayerId?: (playerId: string) => void;
50};
51
52export type PlayerEvent = {
53 id?: string;
54 time: string;
55 playerId: string;
56 eventType: string;
57 meta: { [key: string]: any };
58};
59
60export const PROTOCOL_HLS = "hls";
61export const PROTOCOL_PROGRESSIVE_MP4 = "progressive-mp4";
62export const PROTOCOL_PROGRESSIVE_WEBM = "progressive-webm";
63export const PROTOCOL_WEBRTC = "webrtc";
64
65export enum PlayerStatus {
66 START = "start",
67 PLAYING = "playing",
68 STALLED = "stalled",
69 SUSPEND = "suspend",
70 WAITING = "waiting",
71 PAUSE = "pause",
72 MUTE = "mute",
73}
74
75export type PlayerStatusTracker = Partial<Record<PlayerStatus, number>>;