@stepincto/expo-video 1.0.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/README.md +45 -0
- package/android/build.gradle +32 -0
- package/android/src/main/AndroidManifest.xml +20 -0
- package/android/src/main/java/expo/modules/video/AudioFocusManager.kt +241 -0
- package/android/src/main/java/expo/modules/video/FullscreenPlayerActivity.kt +145 -0
- package/android/src/main/java/expo/modules/video/IntervalUpdateClock.kt +54 -0
- package/android/src/main/java/expo/modules/video/MediaMetadataRetriever.kt +89 -0
- package/android/src/main/java/expo/modules/video/PictureInPictureHelperFragment.kt +26 -0
- package/android/src/main/java/expo/modules/video/PlayerViewExtension.kt +36 -0
- package/android/src/main/java/expo/modules/video/VideoCache.kt +104 -0
- package/android/src/main/java/expo/modules/video/VideoExceptions.kt +34 -0
- package/android/src/main/java/expo/modules/video/VideoManager.kt +133 -0
- package/android/src/main/java/expo/modules/video/VideoModule.kt +414 -0
- package/android/src/main/java/expo/modules/video/VideoThumbnail.kt +20 -0
- package/android/src/main/java/expo/modules/video/VideoView.kt +367 -0
- package/android/src/main/java/expo/modules/video/delegates/IgnoreSameSet.kt +24 -0
- package/android/src/main/java/expo/modules/video/drawing/OutlineProvider.kt +217 -0
- package/android/src/main/java/expo/modules/video/enums/AudioMixingMode.kt +20 -0
- package/android/src/main/java/expo/modules/video/enums/ContentFit.kt +19 -0
- package/android/src/main/java/expo/modules/video/enums/ContentType.kt +22 -0
- package/android/src/main/java/expo/modules/video/enums/DRMType.kt +26 -0
- package/android/src/main/java/expo/modules/video/enums/PlayerStatus.kt +10 -0
- package/android/src/main/java/expo/modules/video/playbackService/ExpoVideoPlaybackService.kt +184 -0
- package/android/src/main/java/expo/modules/video/playbackService/PlaybackServiceConnection.kt +39 -0
- package/android/src/main/java/expo/modules/video/playbackService/VideoMediaSessionCallback.kt +47 -0
- package/android/src/main/java/expo/modules/video/player/FirstFrameEventGenerator.kt +93 -0
- package/android/src/main/java/expo/modules/video/player/PlayerEvent.kt +164 -0
- package/android/src/main/java/expo/modules/video/player/VideoPlayer.kt +460 -0
- package/android/src/main/java/expo/modules/video/player/VideoPlayerAudioTracks.kt +125 -0
- package/android/src/main/java/expo/modules/video/player/VideoPlayerListener.kt +32 -0
- package/android/src/main/java/expo/modules/video/player/VideoPlayerLoadControl.kt +525 -0
- package/android/src/main/java/expo/modules/video/player/VideoPlayerSubtitles.kt +125 -0
- package/android/src/main/java/expo/modules/video/records/BufferOptions.kt +15 -0
- package/android/src/main/java/expo/modules/video/records/DRMOptions.kt +25 -0
- package/android/src/main/java/expo/modules/video/records/PlaybackError.kt +19 -0
- package/android/src/main/java/expo/modules/video/records/Tracks.kt +81 -0
- package/android/src/main/java/expo/modules/video/records/VideoEventPayloads.kt +79 -0
- package/android/src/main/java/expo/modules/video/records/VideoMetadata.kt +12 -0
- package/android/src/main/java/expo/modules/video/records/VideoSize.kt +14 -0
- package/android/src/main/java/expo/modules/video/records/VideoSource.kt +104 -0
- package/android/src/main/java/expo/modules/video/records/VideoThumbnailOptions.kt +24 -0
- package/android/src/main/java/expo/modules/video/utils/DataSourceUtils.kt +75 -0
- package/android/src/main/java/expo/modules/video/utils/EventDispatcherUtils.kt +43 -0
- package/android/src/main/java/expo/modules/video/utils/MutableWeakReference.kt +15 -0
- package/android/src/main/java/expo/modules/video/utils/PictureInPictureUtils.kt +96 -0
- package/android/src/main/java/expo/modules/video/utils/YogaUtils.kt +20 -0
- package/android/src/main/res/drawable/seek_backwards_10s.xml +25 -0
- package/android/src/main/res/drawable/seek_backwards_15s.xml +25 -0
- package/android/src/main/res/drawable/seek_backwards_5s.xml +25 -0
- package/android/src/main/res/drawable/seek_forwards_10s.xml +30 -0
- package/android/src/main/res/drawable/seek_forwards_15s.xml +31 -0
- package/android/src/main/res/drawable/seek_forwards_5s.xml +30 -0
- package/android/src/main/res/layout/fullscreen_player_activity.xml +16 -0
- package/android/src/main/res/layout/surface_player_view.xml +7 -0
- package/android/src/main/res/layout/texture_player_view.xml +7 -0
- package/android/src/main/res/values/styles.xml +9 -0
- package/app.plugin.js +1 -0
- package/build/NativeVideoModule.d.ts +16 -0
- package/build/NativeVideoModule.d.ts.map +1 -0
- package/build/NativeVideoModule.js +3 -0
- package/build/NativeVideoModule.js.map +1 -0
- package/build/NativeVideoModule.web.d.ts +3 -0
- package/build/NativeVideoModule.web.d.ts.map +1 -0
- package/build/NativeVideoModule.web.js +2 -0
- package/build/NativeVideoModule.web.js.map +1 -0
- package/build/NativeVideoView.d.ts +4 -0
- package/build/NativeVideoView.d.ts.map +1 -0
- package/build/NativeVideoView.js +6 -0
- package/build/NativeVideoView.js.map +1 -0
- package/build/VideoModule.d.ts +38 -0
- package/build/VideoModule.d.ts.map +1 -0
- package/build/VideoModule.js +53 -0
- package/build/VideoModule.js.map +1 -0
- package/build/VideoPlayer.d.ts +15 -0
- package/build/VideoPlayer.d.ts.map +1 -0
- package/build/VideoPlayer.js +52 -0
- package/build/VideoPlayer.js.map +1 -0
- package/build/VideoPlayer.types.d.ts +532 -0
- package/build/VideoPlayer.types.d.ts.map +1 -0
- package/build/VideoPlayer.types.js +2 -0
- package/build/VideoPlayer.types.js.map +1 -0
- package/build/VideoPlayer.web.d.ts +75 -0
- package/build/VideoPlayer.web.d.ts.map +1 -0
- package/build/VideoPlayer.web.js +376 -0
- package/build/VideoPlayer.web.js.map +1 -0
- package/build/VideoPlayerEvents.types.d.ts +262 -0
- package/build/VideoPlayerEvents.types.d.ts.map +1 -0
- package/build/VideoPlayerEvents.types.js +2 -0
- package/build/VideoPlayerEvents.types.js.map +1 -0
- package/build/VideoThumbnail.d.ts +29 -0
- package/build/VideoThumbnail.d.ts.map +1 -0
- package/build/VideoThumbnail.js +3 -0
- package/build/VideoThumbnail.js.map +1 -0
- package/build/VideoView.d.ts +44 -0
- package/build/VideoView.d.ts.map +1 -0
- package/build/VideoView.js +76 -0
- package/build/VideoView.js.map +1 -0
- package/build/VideoView.types.d.ts +147 -0
- package/build/VideoView.types.d.ts.map +1 -0
- package/build/VideoView.types.js +2 -0
- package/build/VideoView.types.js.map +1 -0
- package/build/VideoView.web.d.ts +9 -0
- package/build/VideoView.web.d.ts.map +1 -0
- package/build/VideoView.web.js +180 -0
- package/build/VideoView.web.js.map +1 -0
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -0
- package/build/resolveAssetSource.d.ts +3 -0
- package/build/resolveAssetSource.d.ts.map +1 -0
- package/build/resolveAssetSource.js +3 -0
- package/build/resolveAssetSource.js.map +1 -0
- package/build/resolveAssetSource.web.d.ts +4 -0
- package/build/resolveAssetSource.web.d.ts.map +1 -0
- package/build/resolveAssetSource.web.js +16 -0
- package/build/resolveAssetSource.web.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/Cache/CachableRequest.swift +44 -0
- package/ios/Cache/CachedResource.swift +97 -0
- package/ios/Cache/CachingHelpers.swift +92 -0
- package/ios/Cache/MediaFileHandle.swift +94 -0
- package/ios/Cache/MediaInfo.swift +147 -0
- package/ios/Cache/ResourceLoaderDelegate.swift +274 -0
- package/ios/Cache/SynchronizedHashTable.swift +23 -0
- package/ios/Cache/VideoCacheManager.swift +338 -0
- package/ios/ContentKeyDelegate.swift +214 -0
- package/ios/ContentKeyManager.swift +21 -0
- package/ios/Enums/AudioMixingMode.swift +37 -0
- package/ios/Enums/ContentType.swift +12 -0
- package/ios/Enums/DRMType.swift +20 -0
- package/ios/Enums/PlayerStatus.swift +10 -0
- package/ios/Enums/VideoContentFit.swift +39 -0
- package/ios/ExpoVideo.podspec +29 -0
- package/ios/NowPlayingManager.swift +296 -0
- package/ios/Records/BufferOptions.swift +12 -0
- package/ios/Records/DRMOptions.swift +24 -0
- package/ios/Records/PlaybackError.swift +10 -0
- package/ios/Records/Tracks.swift +176 -0
- package/ios/Records/VideoEventPayloads.swift +76 -0
- package/ios/Records/VideoMetadata.swift +16 -0
- package/ios/Records/VideoSize.swift +15 -0
- package/ios/Records/VideoSource.swift +25 -0
- package/ios/Thumbnails/VideoThumbnail.swift +27 -0
- package/ios/Thumbnails/VideoThumbnailGenerator.swift +68 -0
- package/ios/Thumbnails/VideoThumbnailOptions.swift +15 -0
- package/ios/VideoAsset.swift +123 -0
- package/ios/VideoExceptions.swift +53 -0
- package/ios/VideoItem.swift +11 -0
- package/ios/VideoManager.swift +140 -0
- package/ios/VideoModule.swift +383 -0
- package/ios/VideoPlayer/DangerousPropertiesStore.swift +19 -0
- package/ios/VideoPlayer.swift +435 -0
- package/ios/VideoPlayerAudioTracks.swift +72 -0
- package/ios/VideoPlayerItem.swift +97 -0
- package/ios/VideoPlayerObserver.swift +523 -0
- package/ios/VideoPlayerSubtitles.swift +71 -0
- package/ios/VideoSourceLoader.swift +89 -0
- package/ios/VideoSourceLoaderListener.swift +34 -0
- package/ios/VideoView.swift +224 -0
- package/package.json +59 -0
- package/plugin/build/tsconfig.tsbuildinfo +1 -0
- package/plugin/build/withExpoVideo.d.ts +7 -0
- package/plugin/build/withExpoVideo.js +38 -0
- package/src/NativeVideoModule.ts +20 -0
- package/src/NativeVideoModule.web.ts +1 -0
- package/src/NativeVideoView.ts +8 -0
- package/src/VideoModule.ts +59 -0
- package/src/VideoPlayer.tsx +67 -0
- package/src/VideoPlayer.types.ts +613 -0
- package/src/VideoPlayer.web.tsx +451 -0
- package/src/VideoPlayerEvents.types.ts +313 -0
- package/src/VideoThumbnail.ts +31 -0
- package/src/VideoView.tsx +86 -0
- package/src/VideoView.types.ts +165 -0
- package/src/VideoView.web.tsx +214 -0
- package/src/index.ts +46 -0
- package/src/resolveAssetSource.ts +2 -0
- package/src/resolveAssetSource.web.ts +17 -0
- package/src/ts-declarations/react-native-assets.d.ts +1 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PlayerError,
|
|
3
|
+
SubtitleTrack,
|
|
4
|
+
VideoPlayerStatus,
|
|
5
|
+
VideoSource,
|
|
6
|
+
VideoTrack,
|
|
7
|
+
AudioTrack,
|
|
8
|
+
} from './VideoPlayer.types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Handlers for events which can be emitted by the player.
|
|
12
|
+
*/
|
|
13
|
+
export type VideoPlayerEvents = {
|
|
14
|
+
/**
|
|
15
|
+
* Handler for an event emitted when the status of the player changes.
|
|
16
|
+
*/
|
|
17
|
+
statusChange(payload: StatusChangeEventPayload): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Handler for an event emitted when the player starts or stops playback.
|
|
21
|
+
*/
|
|
22
|
+
playingChange(payload: PlayingChangeEventPayload): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handler for an event emitted when the `playbackRate` property of the player changes.
|
|
26
|
+
*/
|
|
27
|
+
playbackRateChange(payload: PlaybackRateChangeEventPayload): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Handler for an event emitted when the `volume` of `muted` property of the player changes.
|
|
31
|
+
*/
|
|
32
|
+
volumeChange(payload: VolumeChangeEventPayload): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Handler for an event emitted when the `muted` property of the player changes
|
|
36
|
+
*/
|
|
37
|
+
mutedChange(payload: MutedChangeEventPayload): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Handler for an event emitted when the player plays to the end of the current source.
|
|
41
|
+
*/
|
|
42
|
+
playToEnd(): void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Handler for an event emitted in a given interval specified by the `timeUpdateEventInterval`.
|
|
46
|
+
*/
|
|
47
|
+
timeUpdate(payload: TimeUpdateEventPayload): void;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Handler for an event emitted when the current media source of the player changes.
|
|
51
|
+
*/
|
|
52
|
+
sourceChange(payload: SourceChangeEventPayload): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Handler for an event emitted when the available subtitle tracks change.
|
|
56
|
+
*/
|
|
57
|
+
availableSubtitleTracksChange(payload: AvailableSubtitleTracksChangeEventPayload): void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Handler for an event emitted when the current subtitle track changes.
|
|
61
|
+
*/
|
|
62
|
+
subtitleTrackChange(payload: SubtitleTrackChangeEventPayload): void;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Handler for an event emitted when the available audio tracks change.
|
|
66
|
+
*/
|
|
67
|
+
availableAudioTracksChange(payload: AvailableAudioTracksChangeEventPayload): void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Handler for an event emitted when the current audio track changes.
|
|
71
|
+
*/
|
|
72
|
+
audioTrackChange(payload: AudioTrackChangeEventPayload): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handler for an event emitted when the current video track changes.
|
|
76
|
+
*/
|
|
77
|
+
videoTrackChange(payload: VideoTrackChangeEventPayload): void;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Handler for an event emitted when the player has finished loading metadata for the current video source.
|
|
81
|
+
* This event is emitted when the player has finished metadata for a [`VideoSource`](#videosource), but it doesn't mean that there is enough data buffered to start the playback.
|
|
82
|
+
*/
|
|
83
|
+
sourceLoad(payload: SourceLoadEventPayload): void;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Data delivered with the [`statusChange`](#videoplayerevents) event.
|
|
88
|
+
*/
|
|
89
|
+
export type StatusChangeEventPayload = {
|
|
90
|
+
/**
|
|
91
|
+
* New status of the player.
|
|
92
|
+
*/
|
|
93
|
+
status: VideoPlayerStatus;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Previous status of the player.
|
|
97
|
+
*/
|
|
98
|
+
oldStatus?: VideoPlayerStatus;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Error object containing information about the error that occurred.
|
|
102
|
+
*/
|
|
103
|
+
error?: PlayerError;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Data delivered with the [`playingChange`](#videoplayerevents) event.
|
|
108
|
+
*/
|
|
109
|
+
export type PlayingChangeEventPayload = {
|
|
110
|
+
/**
|
|
111
|
+
* Boolean value whether the player is currently playing.
|
|
112
|
+
*/
|
|
113
|
+
isPlaying: boolean;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Previous value of the `isPlaying` property.
|
|
117
|
+
*/
|
|
118
|
+
oldIsPlaying?: boolean;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Data delivered with the [`playbackRateChange`](#videoplayerevents) event.
|
|
123
|
+
*/
|
|
124
|
+
export type PlaybackRateChangeEventPayload = {
|
|
125
|
+
/**
|
|
126
|
+
* Float value indicating the current playback speed of the player.
|
|
127
|
+
*/
|
|
128
|
+
playbackRate: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Previous value of the `playbackRate` property.
|
|
132
|
+
*/
|
|
133
|
+
oldPlaybackRate?: number;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Data delivered with the [`volumeChange`](#videoplayerevents) event.
|
|
138
|
+
*/
|
|
139
|
+
export type VolumeChangeEventPayload = {
|
|
140
|
+
/**
|
|
141
|
+
* Float value indicating the current volume of the player.
|
|
142
|
+
*/
|
|
143
|
+
volume: number;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Previous value of the `volume` property.
|
|
147
|
+
*/
|
|
148
|
+
oldVolume?: number;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Data delivered with the [`mutedChange`](#videoplayerevents) event.
|
|
153
|
+
*/
|
|
154
|
+
export type MutedChangeEventPayload = {
|
|
155
|
+
/**
|
|
156
|
+
* Boolean value whether the player is currently muted.
|
|
157
|
+
*/
|
|
158
|
+
muted: boolean;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Previous value of the `isMuted` property.
|
|
162
|
+
*/
|
|
163
|
+
oldMuted?: boolean;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Data delivered with the [`sourceChange`](#videoplayerevents) event.
|
|
168
|
+
*/
|
|
169
|
+
export type SourceChangeEventPayload = {
|
|
170
|
+
/**
|
|
171
|
+
* New source of the player.
|
|
172
|
+
*/
|
|
173
|
+
source: VideoSource;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Previous source of the player.
|
|
177
|
+
*/
|
|
178
|
+
oldSource?: VideoSource;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Data delivered with the [`timeUpdate`](#videoplayerevents) event, contains information about the current playback progress.
|
|
183
|
+
*/
|
|
184
|
+
export type TimeUpdateEventPayload = {
|
|
185
|
+
/**
|
|
186
|
+
* Float value indicating the current playback time in seconds. Same as the [`currentTime`](#currenttime) property.
|
|
187
|
+
*/
|
|
188
|
+
currentTime: number;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The exact timestamp when the currently displayed video frame was sent from the server,
|
|
192
|
+
* based on the `EXT-X-PROGRAM-DATE-TIME` tag in the livestream metadata.
|
|
193
|
+
* Same as the [`currentLiveTimestamp`](#currentlivetimestamp) property.
|
|
194
|
+
* @platform android
|
|
195
|
+
* @platform ios
|
|
196
|
+
*/
|
|
197
|
+
currentLiveTimestamp: number | null;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Float value indicating the latency of the live stream in seconds.
|
|
201
|
+
* Same as the [`currentOffsetFromLive`](#currentoffsetfromlive) property.
|
|
202
|
+
* @platform android
|
|
203
|
+
* @platform ios
|
|
204
|
+
*/
|
|
205
|
+
currentOffsetFromLive: number | null;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Float value indicating how far the player has buffered the video in seconds.
|
|
209
|
+
* Same as the [`bufferedPosition`](#bufferedPosition) property.
|
|
210
|
+
* @platform android
|
|
211
|
+
* @platform ios
|
|
212
|
+
*/
|
|
213
|
+
bufferedPosition: number;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export type SubtitleTrackChangeEventPayload = {
|
|
217
|
+
/**
|
|
218
|
+
* New subtitle track of the player.
|
|
219
|
+
*/
|
|
220
|
+
subtitleTrack: SubtitleTrack | null;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Previous subtitle track of the player.
|
|
224
|
+
*/
|
|
225
|
+
oldSubtitleTrack?: SubtitleTrack | null;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Data delivered with the [`videoTrackChange`](#videoplayerevents) event, contains information about the video track which is currently being played.
|
|
230
|
+
*/
|
|
231
|
+
export type VideoTrackChangeEventPayload = {
|
|
232
|
+
/**
|
|
233
|
+
* New video track of the player.
|
|
234
|
+
*/
|
|
235
|
+
videoTrack: VideoTrack | null;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Previous video track of the player.
|
|
239
|
+
*/
|
|
240
|
+
oldVideoTrack?: VideoTrack | null;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* TODO @behenate: For SDK53 mark as deprecated in favor of SourceLoadEventPayload
|
|
245
|
+
* @hidden
|
|
246
|
+
*/
|
|
247
|
+
export type AvailableSubtitleTracksChangeEventPayload = {
|
|
248
|
+
/**
|
|
249
|
+
* Array of available subtitle tracks.
|
|
250
|
+
*/
|
|
251
|
+
availableSubtitleTracks: SubtitleTrack[];
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Previous array of available subtitle tracks.
|
|
255
|
+
*/
|
|
256
|
+
oldAvailableSubtitleTracks?: SubtitleTrack[];
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Data delivered with the [`sourceLoad`](#videoplayerevents) event, contains information about the video source that has finished loading.
|
|
261
|
+
*/
|
|
262
|
+
export type SourceLoadEventPayload = {
|
|
263
|
+
/**
|
|
264
|
+
* The video source that has been loaded.
|
|
265
|
+
*/
|
|
266
|
+
videoSource: VideoSource | null;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Duration of the video source in seconds.
|
|
270
|
+
*/
|
|
271
|
+
duration: number;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Video tracks available for the loaded video source.
|
|
275
|
+
*
|
|
276
|
+
* > On iOS, when using a HLS source, make sure that the uri contains `.m3u8` extension or that the [`contentType`](#contenttype) property of the [`VideoSource`](#videosource) has been set to `'hls'`. Otherwise, the video tracks will not be available.
|
|
277
|
+
*/
|
|
278
|
+
availableVideoTracks: VideoTrack[];
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Subtitle tracks available for the loaded video source.
|
|
282
|
+
*/
|
|
283
|
+
availableSubtitleTracks: SubtitleTrack[];
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Audio tracks available for the loaded video source.
|
|
287
|
+
*/
|
|
288
|
+
availableAudioTracks: AudioTrack[];
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
type AudioTrackChangeEventPayload = {
|
|
292
|
+
/**
|
|
293
|
+
* New audio track of the player.
|
|
294
|
+
*/
|
|
295
|
+
audioTrack: AudioTrack | null;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Previous audio track of the player.
|
|
299
|
+
*/
|
|
300
|
+
oldAudioTrack?: AudioTrack | null;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
type AvailableAudioTracksChangeEventPayload = {
|
|
304
|
+
/**
|
|
305
|
+
* Array of available audio tracks.
|
|
306
|
+
*/
|
|
307
|
+
availableAudioTracks: AudioTrack[];
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Previous array of available audio tracks.
|
|
311
|
+
*/
|
|
312
|
+
oldAvailableAudioTracks?: AudioTrack[];
|
|
313
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SharedRef } from 'expo';
|
|
2
|
+
|
|
3
|
+
import NativeVideoModule from './NativeVideoModule';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a video thumbnail that references a native image.
|
|
7
|
+
* Instances of this class can be passed as a source to the `Image` component from `expo-image`.
|
|
8
|
+
* @platform android
|
|
9
|
+
* @platform ios
|
|
10
|
+
*/
|
|
11
|
+
export declare class VideoThumbnail extends SharedRef<'image'> {
|
|
12
|
+
/**
|
|
13
|
+
* Width of the created thumbnail.
|
|
14
|
+
*/
|
|
15
|
+
width: number;
|
|
16
|
+
/**
|
|
17
|
+
* Height of the created thumbnail.
|
|
18
|
+
*/
|
|
19
|
+
height: number;
|
|
20
|
+
/**
|
|
21
|
+
* The time in seconds at which the thumbnail was to be created.
|
|
22
|
+
*/
|
|
23
|
+
requestedTime: number;
|
|
24
|
+
/**
|
|
25
|
+
* The time in seconds at which the thumbnail was actually generated.
|
|
26
|
+
* @platform ios
|
|
27
|
+
*/
|
|
28
|
+
actualTime: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default NativeVideoModule.VideoThumbnail;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ReactNode, PureComponent, createRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import NativeVideoModule from './NativeVideoModule';
|
|
4
|
+
import NativeVideoView, { NativeTextureVideoView } from './NativeVideoView';
|
|
5
|
+
import type { VideoPlayer } from './VideoPlayer.types';
|
|
6
|
+
import type { VideoViewProps } from './VideoView.types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns whether the current device supports Picture in Picture (PiP) mode.
|
|
10
|
+
*
|
|
11
|
+
* > **Note:** All major web browsers support Picture in Picture (PiP) mode except Firefox.
|
|
12
|
+
* > For more information, see [MDN web docs](https://developer.mozilla.org/en-US/docs/Web/API/Picture-in-Picture_API#browser_compatibility).
|
|
13
|
+
* @returns A `boolean` which is `true` if the device supports PiP mode, and `false` otherwise.
|
|
14
|
+
* @platform android
|
|
15
|
+
* @platform ios
|
|
16
|
+
* @platform web
|
|
17
|
+
*/
|
|
18
|
+
export function isPictureInPictureSupported(): boolean {
|
|
19
|
+
return NativeVideoModule.isPictureInPictureSupported();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class VideoView extends PureComponent<VideoViewProps> {
|
|
23
|
+
nativeRef = createRef<any>();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Enters fullscreen mode.
|
|
27
|
+
*/
|
|
28
|
+
async enterFullscreen(): Promise<void> {
|
|
29
|
+
return await this.nativeRef.current?.enterFullscreen();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Exits fullscreen mode.
|
|
34
|
+
*/
|
|
35
|
+
async exitFullscreen(): Promise<void> {
|
|
36
|
+
return await this.nativeRef.current?.exitFullscreen();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Enters Picture in Picture (PiP) mode. Throws an exception if the device does not support PiP.
|
|
41
|
+
* > **Note:** Only one player can be in Picture in Picture (PiP) mode at a time.
|
|
42
|
+
*
|
|
43
|
+
* > **Note:** The `supportsPictureInPicture` property of the [config plugin](#configuration-in-app-config)
|
|
44
|
+
* > has to be configured for the PiP to work.
|
|
45
|
+
* @platform android
|
|
46
|
+
* @platform ios
|
|
47
|
+
* @platform web
|
|
48
|
+
*/
|
|
49
|
+
async startPictureInPicture(): Promise<void> {
|
|
50
|
+
return await this.nativeRef.current?.startPictureInPicture();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Exits Picture in Picture (PiP) mode.
|
|
55
|
+
* @platform android
|
|
56
|
+
* @platform ios
|
|
57
|
+
* @platform web
|
|
58
|
+
*/
|
|
59
|
+
async stopPictureInPicture(): Promise<void> {
|
|
60
|
+
return await this.nativeRef.current?.stopPictureInPicture();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render(): ReactNode {
|
|
64
|
+
const { player, ...props } = this.props;
|
|
65
|
+
const playerId = getPlayerId(player);
|
|
66
|
+
|
|
67
|
+
if (NativeTextureVideoView && this.props.surfaceType === 'textureView') {
|
|
68
|
+
return <NativeTextureVideoView {...props} player={playerId} ref={this.nativeRef} />;
|
|
69
|
+
}
|
|
70
|
+
return <NativeVideoView {...props} player={playerId} ref={this.nativeRef} />;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Temporary solution to pass the shared object ID instead of the player object.
|
|
75
|
+
// We can't really pass it as an object in the old architecture.
|
|
76
|
+
// Technically we can in the new architecture, but it's not possible yet.
|
|
77
|
+
function getPlayerId(player: number | VideoPlayer): number | null {
|
|
78
|
+
if (player instanceof NativeVideoModule.VideoPlayer) {
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
return player.__expo_shared_object_id__;
|
|
81
|
+
}
|
|
82
|
+
if (typeof player === 'number') {
|
|
83
|
+
return player;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { VideoPlayer } from './VideoPlayer.types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Describes how a video should be scaled to fit in a container.
|
|
7
|
+
* - `contain`: The video maintains its aspect ratio and fits inside the container, with possible letterboxing/pillarboxing.
|
|
8
|
+
* - `cover`: The video maintains its aspect ratio and covers the entire container, potentially cropping some portions.
|
|
9
|
+
* - `fill`: The video stretches/squeezes to completely fill the container, potentially causing distortion.
|
|
10
|
+
*/
|
|
11
|
+
export type VideoContentFit = 'contain' | 'cover' | 'fill';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Describes the type of the surface used to render the video.
|
|
15
|
+
* - `surfaceView`: Uses the `SurfaceView` to render the video. This value should be used in the majority of cases. Provides significantly lower power consumption, better performance, and more features.
|
|
16
|
+
* - `textureView`: Uses the `TextureView` to render the video. Should be used in cases where the SurfaceView is not supported or causes issues (for example, overlapping video views).
|
|
17
|
+
*
|
|
18
|
+
* You can learn more about surface types in the official [ExoPlayer documentation](https://developer.android.com/media/media3/ui/playerview#surfacetype).
|
|
19
|
+
* @platform android
|
|
20
|
+
*/
|
|
21
|
+
export type SurfaceType = 'textureView' | 'surfaceView';
|
|
22
|
+
|
|
23
|
+
export interface VideoViewProps extends ViewProps {
|
|
24
|
+
/**
|
|
25
|
+
* A video player instance. Use [`useVideoPlayer()`](#usevideoplayersource-setup) hook to create one.
|
|
26
|
+
*/
|
|
27
|
+
player: VideoPlayer;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Determines whether native controls should be displayed or not.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
nativeControls?: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Describes how the video should be scaled to fit in the container.
|
|
37
|
+
* Options are `'contain'`, `'cover'`, and `'fill'`.
|
|
38
|
+
* @default 'contain'
|
|
39
|
+
*/
|
|
40
|
+
contentFit?: VideoContentFit;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Determines whether fullscreen mode is allowed or not.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
allowsFullscreen?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Determines whether the timecodes should be displayed or not.
|
|
50
|
+
* @default true
|
|
51
|
+
* @platform ios
|
|
52
|
+
*/
|
|
53
|
+
showsTimecodes?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Determines whether the player allows the user to skip media content.
|
|
57
|
+
* @default false
|
|
58
|
+
* @platform android
|
|
59
|
+
* @platform ios
|
|
60
|
+
*/
|
|
61
|
+
requiresLinearPlayback?: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Determines the type of the surface used to render the video.
|
|
65
|
+
* > This prop should not be changed at runtime.
|
|
66
|
+
* @default 'surfaceView'
|
|
67
|
+
* @platform android
|
|
68
|
+
*/
|
|
69
|
+
surfaceType?: SurfaceType;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Determines the position offset of the video inside the container.
|
|
73
|
+
* @default { dx: 0, dy: 0 }
|
|
74
|
+
* @platform ios
|
|
75
|
+
*/
|
|
76
|
+
contentPosition?: { dx?: number; dy?: number };
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A callback to call after the video player enters Picture in Picture (PiP) mode.
|
|
80
|
+
* @platform android
|
|
81
|
+
* @platform ios
|
|
82
|
+
* @platform web
|
|
83
|
+
*/
|
|
84
|
+
onPictureInPictureStart?: () => void;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A callback to call after the video player exits Picture in Picture (PiP) mode.
|
|
88
|
+
* @platform android
|
|
89
|
+
* @platform ios
|
|
90
|
+
* @platform web
|
|
91
|
+
*/
|
|
92
|
+
onPictureInPictureStop?: () => void;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Determines whether the player allows Picture in Picture (PiP) mode.
|
|
96
|
+
* > **Note:** The `supportsPictureInPicture` property of the [config plugin](#configuration-in-app-config)
|
|
97
|
+
* > has to be configured for the PiP to work.
|
|
98
|
+
* @platform android
|
|
99
|
+
* @platform ios
|
|
100
|
+
* @platform web
|
|
101
|
+
*/
|
|
102
|
+
allowsPictureInPicture?: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Determines whether a video should be played "inline", that is, within the element's playback area.
|
|
106
|
+
* @platform web
|
|
107
|
+
*/
|
|
108
|
+
playsInline?: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Determines whether the player should start Picture in Picture (PiP) automatically when the app is in the background.
|
|
112
|
+
* > **Note:** Only one player can be in Picture in Picture (PiP) mode at a time.
|
|
113
|
+
*
|
|
114
|
+
* > **Note:** The `supportsPictureInPicture` property of the [config plugin](#configuration-in-app-config)
|
|
115
|
+
* > has to be configured for the PiP to work.
|
|
116
|
+
*
|
|
117
|
+
* @default false
|
|
118
|
+
* @platform android 12+
|
|
119
|
+
* @platform ios
|
|
120
|
+
*/
|
|
121
|
+
startsPictureInPictureAutomatically?: boolean;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Specifies whether to perform video frame analysis (Live Text in videos).
|
|
125
|
+
* Check official [Apple documentation](https://developer.apple.com/documentation/avkit/avplayerviewcontroller/allowsvideoframeanalysis) for more details.
|
|
126
|
+
* @default true
|
|
127
|
+
* @platform ios 16.0+
|
|
128
|
+
*/
|
|
129
|
+
allowsVideoFrameAnalysis?: boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A callback to call after the video player enters fullscreen mode.
|
|
133
|
+
*/
|
|
134
|
+
onFullscreenEnter?: () => void;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A callback to call after the video player exits fullscreen mode.
|
|
138
|
+
*/
|
|
139
|
+
onFullscreenExit?: () => void;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* A callback to call after the mounted `VideoPlayer` has rendered the first frame into the `VideoView`.
|
|
143
|
+
* This event can be used to hide any cover images that conceal the initial loading of the player.
|
|
144
|
+
* > **Note:** This event may also be called during playback when the current video track changes (for example when the player switches video quality).
|
|
145
|
+
*/
|
|
146
|
+
onFirstFrameRender?: () => void;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Determines whether the player should use the default ExoPlayer shutter that covers the `VideoView` before the first video frame is rendered.
|
|
150
|
+
* Setting this property to `false` makes the Android behavior the same as iOS.
|
|
151
|
+
*
|
|
152
|
+
* @platform android
|
|
153
|
+
* @default false
|
|
154
|
+
*/
|
|
155
|
+
useExoShutter?: boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Determines the [cross origin policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/crossorigin) used by the underlying native view on web.
|
|
159
|
+
* If undefined, does not use CORS at all.
|
|
160
|
+
*
|
|
161
|
+
* @platform web
|
|
162
|
+
* @default undefined
|
|
163
|
+
*/
|
|
164
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
165
|
+
}
|