@mux/mux-react-native-player 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MuxReactNativePlayer.podspec +37 -0
- package/README.md +134 -0
- package/android/build.gradle +33 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/mux/reactnativeplayer/MuxReactNativePlayerModule.kt +135 -0
- package/android/src/main/java/com/mux/reactnativeplayer/MuxVideoRecords.kt +174 -0
- package/android/src/main/java/com/mux/reactnativeplayer/MuxVideoView.kt +452 -0
- package/android/src/main/res/layout/mux_video_player_view.xml +6 -0
- package/assets/MuxRobot_02.gif +0 -0
- package/assets/MuxRobot_02@2x.gif +0 -0
- package/assets/MuxRobot_03.gif +0 -0
- package/assets/MuxRobot_03@2x.gif +0 -0
- package/assets/MuxRobot_04.gif +0 -0
- package/assets/MuxRobot_04@2x.gif +0 -0
- package/assets/MuxRobot_05.gif +0 -0
- package/assets/MuxRobot_05@2x.gif +0 -0
- package/build/MuxVideoControls.d.ts +21 -0
- package/build/MuxVideoControls.d.ts.map +1 -0
- package/build/MuxVideoControls.js +1032 -0
- package/build/MuxVideoPlayer.d.ts +59 -0
- package/build/MuxVideoPlayer.d.ts.map +1 -0
- package/build/MuxVideoPlayer.js +265 -0
- package/build/MuxVideoView.d.ts +39 -0
- package/build/MuxVideoView.d.ts.map +1 -0
- package/build/MuxVideoView.js +254 -0
- package/build/NativeMuxVideoView.d.ts +5 -0
- package/build/NativeMuxVideoView.d.ts.map +1 -0
- package/build/NativeMuxVideoView.js +4 -0
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/normalizeSource.d.ts +7 -0
- package/build/normalizeSource.d.ts.map +1 -0
- package/build/normalizeSource.js +76 -0
- package/build/screenOrientation.d.ts +3 -0
- package/build/screenOrientation.d.ts.map +1 -0
- package/build/screenOrientation.js +38 -0
- package/build/types.d.ts +170 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +1 -0
- package/expo-module.config.json +13 -0
- package/ios/MuxReactNativePlayerModule.swift +139 -0
- package/ios/MuxVideoRecords.swift +212 -0
- package/ios/MuxVideoView.swift +502 -0
- package/package.json +69 -0
- package/plugin/index.d.ts +11 -0
- package/plugin/index.js +1 -0
- package/plugin/withMuxReactNativePlayer.js +203 -0
- package/src/MuxVideoControls.tsx +1772 -0
- package/src/MuxVideoPlayer.ts +338 -0
- package/src/MuxVideoView.tsx +412 -0
- package/src/NativeMuxVideoView.ts +15 -0
- package/src/index.ts +32 -0
- package/src/normalizeSource.ts +101 -0
- package/src/screenOrientation.ts +46 -0
- package/src/types.ts +228 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type MuxMaxResolution = '720p' | '1080p' | '1440p' | '2160p';
|
|
4
|
+
export type MuxMinResolution = '480p' | '540p' | '720p' | '1080p' | '1440p' | '2160p';
|
|
5
|
+
export type MuxRenditionOrder = 'default' | 'desc';
|
|
6
|
+
export type MuxContentFit = 'contain' | 'cover' | 'fill';
|
|
7
|
+
export type MuxVideoControls = 'native' | 'custom' | 'none';
|
|
8
|
+
|
|
9
|
+
export type MuxCustomData = Partial<Record<
|
|
10
|
+
| 'customData1'
|
|
11
|
+
| 'customData2'
|
|
12
|
+
| 'customData3'
|
|
13
|
+
| 'customData4'
|
|
14
|
+
| 'customData5'
|
|
15
|
+
| 'customData6'
|
|
16
|
+
| 'customData7'
|
|
17
|
+
| 'customData8'
|
|
18
|
+
| 'customData9'
|
|
19
|
+
| 'customData10',
|
|
20
|
+
string
|
|
21
|
+
>> & Record<string, string | undefined>;
|
|
22
|
+
|
|
23
|
+
export type MuxVideoMetadata = {
|
|
24
|
+
envKey?: string;
|
|
25
|
+
playerName?: string;
|
|
26
|
+
playerVersion?: string;
|
|
27
|
+
videoTitle?: string;
|
|
28
|
+
videoId?: string;
|
|
29
|
+
videoSeries?: string;
|
|
30
|
+
viewerUserId?: string;
|
|
31
|
+
customData?: MuxCustomData;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type MuxVideoClipping = {
|
|
35
|
+
assetStartTime?: number;
|
|
36
|
+
assetEndTime?: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type MuxVideoSourceObject = {
|
|
40
|
+
playbackId: string;
|
|
41
|
+
assetId?: string;
|
|
42
|
+
playbackToken?: string;
|
|
43
|
+
drmToken?: string;
|
|
44
|
+
customDomain?: string;
|
|
45
|
+
minResolution?: MuxMinResolution;
|
|
46
|
+
maxResolution?: MuxMaxResolution;
|
|
47
|
+
renditionOrder?: MuxRenditionOrder;
|
|
48
|
+
clipping?: MuxVideoClipping;
|
|
49
|
+
metadata?: MuxVideoMetadata;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type MuxVideoSource = string | MuxVideoSourceObject;
|
|
53
|
+
|
|
54
|
+
export type NormalizedMuxVideoSource = MuxVideoSourceObject & {
|
|
55
|
+
playbackId: string;
|
|
56
|
+
renditionOrder: MuxRenditionOrder;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type MuxPlaybackStatus =
|
|
60
|
+
| 'idle'
|
|
61
|
+
| 'loading'
|
|
62
|
+
| 'ready'
|
|
63
|
+
| 'buffering'
|
|
64
|
+
| 'playing'
|
|
65
|
+
| 'paused'
|
|
66
|
+
| 'ended'
|
|
67
|
+
| 'error';
|
|
68
|
+
|
|
69
|
+
export type MuxPlayerStatus = {
|
|
70
|
+
status: MuxPlaybackStatus;
|
|
71
|
+
currentTime: number;
|
|
72
|
+
duration: number;
|
|
73
|
+
bufferedPosition: number;
|
|
74
|
+
muted: boolean;
|
|
75
|
+
volume: number;
|
|
76
|
+
loop: boolean;
|
|
77
|
+
playbackRate: number;
|
|
78
|
+
captionTracks?: MuxVideoCaptionTrack[];
|
|
79
|
+
selectedCaptionTrackId?: string | null;
|
|
80
|
+
error?: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type MuxStatusChangeEvent = MuxPlayerStatus;
|
|
84
|
+
|
|
85
|
+
export type MuxPlayingChangeEvent = {
|
|
86
|
+
isPlaying: boolean;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type MuxTimeUpdateEvent = {
|
|
90
|
+
currentTime: number;
|
|
91
|
+
duration: number;
|
|
92
|
+
bufferedPosition: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type MuxVideoRobotsContext = {
|
|
96
|
+
assetId: string;
|
|
97
|
+
duration: number;
|
|
98
|
+
currentTime: number;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type MuxVideoSummary = {
|
|
102
|
+
title: string;
|
|
103
|
+
description: string;
|
|
104
|
+
tags?: string[];
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type MuxVideoChapter = {
|
|
108
|
+
startTime: number;
|
|
109
|
+
title: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type MuxVideoKeyMoment = {
|
|
113
|
+
startTime: number;
|
|
114
|
+
endTime: number;
|
|
115
|
+
title: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
score?: number;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type MuxVideoRobotsConfig = {
|
|
121
|
+
enabled?: boolean;
|
|
122
|
+
assetId?: string;
|
|
123
|
+
summary?: MuxVideoSummary;
|
|
124
|
+
chapters?: MuxVideoChapter[];
|
|
125
|
+
keyMoments?: MuxVideoKeyMoment[];
|
|
126
|
+
onSummarize?: (context: MuxVideoRobotsContext) => Promise<MuxVideoSummary>;
|
|
127
|
+
onGenerateChapters?: (
|
|
128
|
+
context: MuxVideoRobotsContext
|
|
129
|
+
) => Promise<MuxVideoChapter[]>;
|
|
130
|
+
onFindKeyMoments?: (
|
|
131
|
+
context: MuxVideoRobotsContext
|
|
132
|
+
) => Promise<MuxVideoKeyMoment[]>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type MuxSourceLoadEvent = {
|
|
136
|
+
playbackId: string;
|
|
137
|
+
duration: number;
|
|
138
|
+
captionTracks?: MuxVideoCaptionTrack[];
|
|
139
|
+
selectedCaptionTrackId?: string | null;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export type MuxSourceErrorEvent = {
|
|
143
|
+
playbackId?: string;
|
|
144
|
+
message: string;
|
|
145
|
+
code?: string;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type MuxNativeViewRef = {
|
|
149
|
+
play: () => Promise<void>;
|
|
150
|
+
pause: () => Promise<void>;
|
|
151
|
+
replay: () => Promise<void>;
|
|
152
|
+
seekBy: (seconds: number) => Promise<void>;
|
|
153
|
+
seekTo: (seconds: number) => Promise<void>;
|
|
154
|
+
setMuted: (muted: boolean) => Promise<void>;
|
|
155
|
+
setVolume: (volume: number) => Promise<void>;
|
|
156
|
+
setLoop: (loop: boolean) => Promise<void>;
|
|
157
|
+
setPlaybackRate: (rate: number) => Promise<void>;
|
|
158
|
+
setCaptionTrack: (trackId: string | null) => Promise<void>;
|
|
159
|
+
release: () => Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export type MuxVideoCaptionTrack = {
|
|
163
|
+
id: string;
|
|
164
|
+
label: string;
|
|
165
|
+
language?: string;
|
|
166
|
+
kind?: 'subtitles' | 'captions' | 'forced' | string;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export type MuxVideoControlsTheme = {
|
|
170
|
+
accentColor?: string;
|
|
171
|
+
backgroundColor?: string;
|
|
172
|
+
buttonBackgroundColor?: string;
|
|
173
|
+
buttonTextColor?: string;
|
|
174
|
+
buttonSize?: number;
|
|
175
|
+
playButtonSize?: number;
|
|
176
|
+
fullscreenButtonSize?: number;
|
|
177
|
+
progressTrackColor?: string;
|
|
178
|
+
bufferedTrackColor?: string;
|
|
179
|
+
trackColor?: string;
|
|
180
|
+
trackHeight?: number;
|
|
181
|
+
textColor?: string;
|
|
182
|
+
seekSeconds?: number;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export type MuxVideoViewProps = ViewProps & {
|
|
186
|
+
player: import('./MuxVideoPlayer').MuxVideoPlayer;
|
|
187
|
+
controls?: MuxVideoControls;
|
|
188
|
+
controlsTheme?: MuxVideoControlsTheme;
|
|
189
|
+
robots?: MuxVideoRobotsConfig;
|
|
190
|
+
nativeControls?: boolean;
|
|
191
|
+
contentFit?: MuxContentFit;
|
|
192
|
+
allowsFullscreen?: boolean;
|
|
193
|
+
allowsPictureInPicture?: boolean;
|
|
194
|
+
timeUpdateEventInterval?: number;
|
|
195
|
+
startupBufferDuration?: number;
|
|
196
|
+
onStatusChange?: (event: MuxStatusChangeEvent) => void;
|
|
197
|
+
onPlayingChange?: (event: MuxPlayingChangeEvent) => void;
|
|
198
|
+
onTimeUpdate?: (event: MuxTimeUpdateEvent) => void;
|
|
199
|
+
onSourceLoad?: (event: MuxSourceLoadEvent) => void;
|
|
200
|
+
onSourceError?: (event: MuxSourceErrorEvent) => void;
|
|
201
|
+
onFullscreenChange?: (isFullscreen: boolean) => void;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type NativeMuxVideoViewProps = Omit<
|
|
205
|
+
MuxVideoViewProps,
|
|
206
|
+
| 'player'
|
|
207
|
+
| 'controls'
|
|
208
|
+
| 'controlsTheme'
|
|
209
|
+
| 'robots'
|
|
210
|
+
| 'onStatusChange'
|
|
211
|
+
| 'onPlayingChange'
|
|
212
|
+
| 'onTimeUpdate'
|
|
213
|
+
| 'onSourceLoad'
|
|
214
|
+
| 'onSourceError'
|
|
215
|
+
| 'onFullscreenChange'
|
|
216
|
+
> & {
|
|
217
|
+
source?: NormalizedMuxVideoSource;
|
|
218
|
+
playWhenReady: boolean;
|
|
219
|
+
muted: boolean;
|
|
220
|
+
volume: number;
|
|
221
|
+
loop: boolean;
|
|
222
|
+
playbackRate: number;
|
|
223
|
+
onStatusChange?: (event: NativeSyntheticEvent<MuxStatusChangeEvent>) => void;
|
|
224
|
+
onPlayingChange?: (event: NativeSyntheticEvent<MuxPlayingChangeEvent>) => void;
|
|
225
|
+
onTimeUpdate?: (event: NativeSyntheticEvent<MuxTimeUpdateEvent>) => void;
|
|
226
|
+
onSourceLoad?: (event: NativeSyntheticEvent<MuxSourceLoadEvent>) => void;
|
|
227
|
+
onSourceError?: (event: NativeSyntheticEvent<MuxSourceErrorEvent>) => void;
|
|
228
|
+
};
|