@granite-js/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/CHANGELOG.md +7 -0
- package/GraniteVideo.podspec +72 -0
- package/android/README.md +232 -0
- package/android/build.gradle +117 -0
- package/android/gradle.properties +8 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/run/granite/video/GraniteVideoModule.kt +70 -0
- package/android/src/main/java/run/granite/video/GraniteVideoPackage.kt +43 -0
- package/android/src/main/java/run/granite/video/GraniteVideoView.kt +384 -0
- package/android/src/main/java/run/granite/video/GraniteVideoViewManager.kt +318 -0
- package/android/src/main/java/run/granite/video/event/GraniteVideoEvents.kt +273 -0
- package/android/src/main/java/run/granite/video/event/VideoEventDispatcher.kt +66 -0
- package/android/src/main/java/run/granite/video/event/VideoEventListenerAdapter.kt +157 -0
- package/android/src/main/java/run/granite/video/provider/GraniteVideoProvider.kt +346 -0
- package/android/src/media3/AndroidManifest.xml +9 -0
- package/android/src/media3/java/run/granite/video/provider/media3/ExoPlayerProvider.kt +386 -0
- package/android/src/media3/java/run/granite/video/provider/media3/Media3ContentProvider.kt +29 -0
- package/android/src/media3/java/run/granite/video/provider/media3/Media3Initializer.kt +25 -0
- package/android/src/media3/java/run/granite/video/provider/media3/factory/ExoPlayerFactory.kt +32 -0
- package/android/src/media3/java/run/granite/video/provider/media3/factory/MediaSourceFactory.kt +61 -0
- package/android/src/media3/java/run/granite/video/provider/media3/factory/TrackSelectorFactory.kt +26 -0
- package/android/src/media3/java/run/granite/video/provider/media3/factory/VideoSurfaceFactory.kt +62 -0
- package/android/src/media3/java/run/granite/video/provider/media3/listener/ExoPlayerEventListener.kt +104 -0
- package/android/src/media3/java/run/granite/video/provider/media3/scheduler/ProgressScheduler.kt +56 -0
- package/android/src/test/java/run/granite/video/GraniteVideoViewRobolectricTest.kt +598 -0
- package/android/src/test/java/run/granite/video/event/VideoEventListenerAdapterTest.kt +319 -0
- package/android/src/test/java/run/granite/video/helpers/FakeGraniteVideoProvider.kt +161 -0
- package/android/src/test/java/run/granite/video/helpers/TestProgressScheduler.kt +42 -0
- package/android/src/test/java/run/granite/video/provider/GraniteVideoRegistryTest.kt +232 -0
- package/android/src/test/java/run/granite/video/provider/ProviderContractTest.kt +174 -0
- package/android/src/test/java/run/granite/video/provider/media3/listener/ExoPlayerEventListenerTest.kt +243 -0
- package/android/src/test/resources/kotest.properties +2 -0
- package/dist/module/GraniteVideo.js +458 -0
- package/dist/module/GraniteVideo.js.map +1 -0
- package/dist/module/GraniteVideoNativeComponent.ts +265 -0
- package/dist/module/index.js +7 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/types.js +4 -0
- package/dist/module/types.js.map +1 -0
- package/dist/typescript/GraniteVideo.d.ts +12 -0
- package/dist/typescript/GraniteVideoNativeComponent.d.ts +189 -0
- package/dist/typescript/index.d.ts +5 -0
- package/dist/typescript/types.d.ts +328 -0
- package/ios/GraniteVideoComponentsProvider.h +10 -0
- package/ios/GraniteVideoProvider.swift +280 -0
- package/ios/GraniteVideoView.h +15 -0
- package/ios/GraniteVideoView.mm +661 -0
- package/ios/Providers/AVPlayerProvider.swift +541 -0
- package/package.json +106 -0
- package/src/GraniteVideo.tsx +575 -0
- package/src/GraniteVideoNativeComponent.ts +265 -0
- package/src/index.ts +8 -0
- package/src/types.ts +464 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { type ViewProps, type HostComponent, codegenNativeCommands, codegenNativeComponent } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
type Int32,
|
|
4
|
+
type Float,
|
|
5
|
+
type Double,
|
|
6
|
+
type DirectEventHandler,
|
|
7
|
+
type WithDefault,
|
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
9
|
+
|
|
10
|
+
// ============================================================
|
|
11
|
+
// Native Props Interface
|
|
12
|
+
// ============================================================
|
|
13
|
+
|
|
14
|
+
interface NativeVideoSource {
|
|
15
|
+
uri?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
startPosition?: Double;
|
|
18
|
+
cropStart?: Double;
|
|
19
|
+
cropEnd?: Double;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface NativeBufferConfig {
|
|
23
|
+
minBufferMs?: Int32;
|
|
24
|
+
maxBufferMs?: Int32;
|
|
25
|
+
bufferForPlaybackMs?: Int32;
|
|
26
|
+
bufferForPlaybackAfterRebufferMs?: Int32;
|
|
27
|
+
backBufferDurationMs?: Int32;
|
|
28
|
+
cacheSizeMB?: Int32;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface NativeSelectedTrack {
|
|
32
|
+
type?: string;
|
|
33
|
+
value?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface NativeSelectedVideoTrack {
|
|
37
|
+
type?: string;
|
|
38
|
+
value?: Int32;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface NativeDrmConfig {
|
|
42
|
+
type?: string;
|
|
43
|
+
licenseServer?: string;
|
|
44
|
+
contentId?: string;
|
|
45
|
+
certificateUrl?: string;
|
|
46
|
+
base64Certificate?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type OnVideoLoadStartEvent = Readonly<{
|
|
50
|
+
isNetwork: boolean;
|
|
51
|
+
type: string;
|
|
52
|
+
uri: string;
|
|
53
|
+
}>;
|
|
54
|
+
|
|
55
|
+
export type OnVideoLoadEvent = Readonly<{
|
|
56
|
+
currentTime: Double;
|
|
57
|
+
duration: Double;
|
|
58
|
+
naturalSize: {
|
|
59
|
+
width: Double;
|
|
60
|
+
height: Double;
|
|
61
|
+
orientation: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
export type OnVideoErrorEvent = Readonly<{
|
|
66
|
+
error: {
|
|
67
|
+
code: Int32;
|
|
68
|
+
domain: string;
|
|
69
|
+
localizedDescription: string;
|
|
70
|
+
localizedFailureReason: string;
|
|
71
|
+
localizedRecoverySuggestion: string;
|
|
72
|
+
errorString: string;
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
|
|
76
|
+
export type OnVideoProgressEvent = Readonly<{
|
|
77
|
+
currentTime: Double;
|
|
78
|
+
playableDuration: Double;
|
|
79
|
+
seekableDuration: Double;
|
|
80
|
+
}>;
|
|
81
|
+
|
|
82
|
+
export type OnVideoSeekEvent = Readonly<{
|
|
83
|
+
currentTime: Double;
|
|
84
|
+
seekTime: Double;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
export type OnVideoBufferEvent = Readonly<{
|
|
88
|
+
isBuffering: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
|
|
91
|
+
export type OnVideoBandwidthUpdateEvent = Readonly<{
|
|
92
|
+
bitrate: Double;
|
|
93
|
+
width: Int32;
|
|
94
|
+
height: Int32;
|
|
95
|
+
}>;
|
|
96
|
+
|
|
97
|
+
export type OnVideoPlaybackStateChangedEvent = Readonly<{
|
|
98
|
+
isPlaying: boolean;
|
|
99
|
+
isSeeking: boolean;
|
|
100
|
+
isLooping: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
|
|
103
|
+
export type OnVideoPlaybackRateChangeEvent = Readonly<{
|
|
104
|
+
playbackRate: Float;
|
|
105
|
+
}>;
|
|
106
|
+
|
|
107
|
+
export type OnVideoVolumeChangeEvent = Readonly<{
|
|
108
|
+
volume: Float;
|
|
109
|
+
}>;
|
|
110
|
+
|
|
111
|
+
export type OnVideoAudioFocusChangedEvent = Readonly<{
|
|
112
|
+
hasAudioFocus: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
|
|
115
|
+
export type OnVideoPictureInPictureStatusChangedEvent = Readonly<{
|
|
116
|
+
isActive: boolean;
|
|
117
|
+
}>;
|
|
118
|
+
|
|
119
|
+
export type OnVideoControlsVisibilityChangeEvent = Readonly<{
|
|
120
|
+
isVisible: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
export type OnVideoExternalPlaybackChangeEvent = Readonly<{
|
|
124
|
+
isExternalPlaybackActive: boolean;
|
|
125
|
+
}>;
|
|
126
|
+
|
|
127
|
+
export type OnVideoAspectRatioEvent = Readonly<{
|
|
128
|
+
width: Double;
|
|
129
|
+
height: Double;
|
|
130
|
+
}>;
|
|
131
|
+
|
|
132
|
+
export type TransferEndEvent = Readonly<{
|
|
133
|
+
uri: string;
|
|
134
|
+
bytesTransferred: Double;
|
|
135
|
+
}>;
|
|
136
|
+
|
|
137
|
+
export interface NativeProps extends ViewProps {
|
|
138
|
+
// Source
|
|
139
|
+
source?: NativeVideoSource;
|
|
140
|
+
|
|
141
|
+
// Poster
|
|
142
|
+
poster?: string;
|
|
143
|
+
posterResizeMode?: WithDefault<string, 'contain'>;
|
|
144
|
+
|
|
145
|
+
// Playback Control
|
|
146
|
+
paused?: boolean;
|
|
147
|
+
muted?: boolean;
|
|
148
|
+
volume?: Float;
|
|
149
|
+
rate?: Float;
|
|
150
|
+
repeat?: boolean;
|
|
151
|
+
playInBackground?: boolean;
|
|
152
|
+
playWhenInactive?: boolean;
|
|
153
|
+
automaticallyWaitsToMinimizeStalling?: boolean;
|
|
154
|
+
shutterColor?: string;
|
|
155
|
+
|
|
156
|
+
// Display
|
|
157
|
+
resizeMode?: WithDefault<string, 'contain'>;
|
|
158
|
+
viewType?: WithDefault<string, 'surface'>;
|
|
159
|
+
useTextureView?: boolean;
|
|
160
|
+
useSecureView?: boolean;
|
|
161
|
+
|
|
162
|
+
// Buffering
|
|
163
|
+
bufferConfig?: NativeBufferConfig;
|
|
164
|
+
minLoadRetryCount?: Int32;
|
|
165
|
+
maxBitRate?: Int32;
|
|
166
|
+
preferredForwardBufferDuration?: Double;
|
|
167
|
+
|
|
168
|
+
// Track Selection
|
|
169
|
+
selectedAudioTrack?: NativeSelectedTrack;
|
|
170
|
+
selectedTextTrack?: NativeSelectedTrack;
|
|
171
|
+
selectedVideoTrack?: NativeSelectedVideoTrack;
|
|
172
|
+
|
|
173
|
+
// DRM
|
|
174
|
+
drm?: NativeDrmConfig;
|
|
175
|
+
localSourceEncryptionKeyScheme?: string;
|
|
176
|
+
|
|
177
|
+
// Ads
|
|
178
|
+
adTagUrl?: string;
|
|
179
|
+
adLanguage?: string;
|
|
180
|
+
|
|
181
|
+
// Controls
|
|
182
|
+
controls?: boolean;
|
|
183
|
+
showNotificationControls?: boolean;
|
|
184
|
+
disableFocus?: boolean;
|
|
185
|
+
disableDisconnectError?: boolean;
|
|
186
|
+
focusable?: boolean;
|
|
187
|
+
hideShutterView?: boolean;
|
|
188
|
+
preventsDisplaySleepDuringVideoPlayback?: boolean;
|
|
189
|
+
|
|
190
|
+
// Fullscreen
|
|
191
|
+
fullscreen?: boolean;
|
|
192
|
+
fullscreenAutorotate?: boolean;
|
|
193
|
+
fullscreenOrientation?: WithDefault<string, 'all'>;
|
|
194
|
+
|
|
195
|
+
// Picture in Picture
|
|
196
|
+
pictureInPicture?: boolean;
|
|
197
|
+
|
|
198
|
+
// Content
|
|
199
|
+
contentStartTime?: Double;
|
|
200
|
+
allowsExternalPlayback?: boolean;
|
|
201
|
+
audioOutput?: WithDefault<string, 'speaker'>;
|
|
202
|
+
ignoreSilentSwitch?: WithDefault<string, 'inherit'>;
|
|
203
|
+
mixWithOthers?: WithDefault<string, 'inherit'>;
|
|
204
|
+
|
|
205
|
+
// Debug
|
|
206
|
+
enableDebug?: boolean;
|
|
207
|
+
enableDebugThread?: boolean;
|
|
208
|
+
|
|
209
|
+
// === Events ===
|
|
210
|
+
onVideoLoadStart?: DirectEventHandler<OnVideoLoadStartEvent>;
|
|
211
|
+
onVideoLoad?: DirectEventHandler<OnVideoLoadEvent>;
|
|
212
|
+
onVideoError?: DirectEventHandler<OnVideoErrorEvent>;
|
|
213
|
+
onVideoProgress?: DirectEventHandler<OnVideoProgressEvent>;
|
|
214
|
+
onVideoSeek?: DirectEventHandler<OnVideoSeekEvent>;
|
|
215
|
+
onVideoEnd?: DirectEventHandler<null>;
|
|
216
|
+
onVideoBuffer?: DirectEventHandler<OnVideoBufferEvent>;
|
|
217
|
+
onVideoBandwidthUpdate?: DirectEventHandler<OnVideoBandwidthUpdateEvent>;
|
|
218
|
+
onVideoPlaybackStateChanged?: DirectEventHandler<OnVideoPlaybackStateChangedEvent>;
|
|
219
|
+
onVideoPlaybackRateChange?: DirectEventHandler<OnVideoPlaybackRateChangeEvent>;
|
|
220
|
+
onVideoVolumeChange?: DirectEventHandler<OnVideoVolumeChangeEvent>;
|
|
221
|
+
onVideoIdle?: DirectEventHandler<null>;
|
|
222
|
+
onVideoReadyForDisplay?: DirectEventHandler<null>;
|
|
223
|
+
onVideoAudioFocusChanged?: DirectEventHandler<OnVideoAudioFocusChangedEvent>;
|
|
224
|
+
onVideoAudioBecomingNoisy?: DirectEventHandler<null>;
|
|
225
|
+
onVideoFullscreenPlayerWillPresent?: DirectEventHandler<null>;
|
|
226
|
+
onVideoFullscreenPlayerDidPresent?: DirectEventHandler<null>;
|
|
227
|
+
onVideoFullscreenPlayerWillDismiss?: DirectEventHandler<null>;
|
|
228
|
+
onVideoFullscreenPlayerDidDismiss?: DirectEventHandler<null>;
|
|
229
|
+
onVideoPictureInPictureStatusChanged?: DirectEventHandler<OnVideoPictureInPictureStatusChangedEvent>;
|
|
230
|
+
onVideoRestoreUserInterfaceForPictureInPictureStop?: DirectEventHandler<null>;
|
|
231
|
+
onVideoControlsVisibilityChange?: DirectEventHandler<OnVideoControlsVisibilityChangeEvent>;
|
|
232
|
+
onVideoExternalPlaybackChange?: DirectEventHandler<OnVideoExternalPlaybackChangeEvent>;
|
|
233
|
+
onVideoAspectRatio?: DirectEventHandler<OnVideoAspectRatioEvent>;
|
|
234
|
+
onTransferEnd?: DirectEventHandler<TransferEndEvent>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ============================================================
|
|
238
|
+
// Native Commands Interface
|
|
239
|
+
// ============================================================
|
|
240
|
+
|
|
241
|
+
export interface NativeCommands {
|
|
242
|
+
seek: (viewRef: React.ElementRef<HostComponent<NativeProps>>, time: Double, tolerance: Double) => void;
|
|
243
|
+
adjustVolume: (viewRef: React.ElementRef<HostComponent<NativeProps>>, volume: Float) => void;
|
|
244
|
+
setFullScreen: (viewRef: React.ElementRef<HostComponent<NativeProps>>, fullscreen: boolean) => void;
|
|
245
|
+
loadSource: (viewRef: React.ElementRef<HostComponent<NativeProps>>, uri: string) => void;
|
|
246
|
+
pause: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
247
|
+
resume: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
248
|
+
enterPictureInPicture: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
249
|
+
exitPictureInPicture: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
253
|
+
supportedCommands: [
|
|
254
|
+
'seek',
|
|
255
|
+
'adjustVolume',
|
|
256
|
+
'setFullScreen',
|
|
257
|
+
'loadSource',
|
|
258
|
+
'pause',
|
|
259
|
+
'resume',
|
|
260
|
+
'enterPictureInPicture',
|
|
261
|
+
'exitPictureInPicture',
|
|
262
|
+
],
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
export default codegenNativeComponent<NativeProps>('GraniteVideoView');
|
package/src/index.ts
ADDED