expo-libvlc-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.
Files changed (70) hide show
  1. package/.eslintrc.js +2 -0
  2. package/README.md +107 -0
  3. package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
  4. package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
  5. package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
  7. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  9. package/android/.gradle/config.properties +2 -0
  10. package/android/.gradle/ideaInitScripts/ijtgtmapper.gradle +3 -0
  11. package/android/.gradle/vcs-1/gc.properties +0 -0
  12. package/android/.idea/AndroidProjectSystem.xml +6 -0
  13. package/android/.idea/android.iml +9 -0
  14. package/android/.idea/caches/deviceStreaming.xml +835 -0
  15. package/android/.idea/deviceManager.xml +13 -0
  16. package/android/.idea/gradle.xml +13 -0
  17. package/android/.idea/misc.xml +3 -0
  18. package/android/.idea/modules.xml +8 -0
  19. package/android/.idea/runConfigurations.xml +17 -0
  20. package/android/.idea/vcs.xml +6 -0
  21. package/android/.idea/workspace.xml +72 -0
  22. package/android/build.gradle +53 -0
  23. package/android/local.properties +8 -0
  24. package/android/proguard-rules.pro +19 -0
  25. package/android/src/main/AndroidManifest.xml +4 -0
  26. package/android/src/main/java/expo/modules/libvlcplayer/AudioFocusManager.kt +210 -0
  27. package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerManager.kt +82 -0
  28. package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerModule.kt +129 -0
  29. package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerView.kt +328 -0
  30. package/android/src/main/java/expo/modules/libvlcplayer/enums/AudioMixingMode.kt +20 -0
  31. package/app.plugin.js +1 -0
  32. package/build/VlcPlayer.types.d.ts +278 -0
  33. package/build/VlcPlayer.types.d.ts.map +1 -0
  34. package/build/VlcPlayer.types.js +2 -0
  35. package/build/VlcPlayer.types.js.map +1 -0
  36. package/build/VlcPlayerModule.d.ts +6 -0
  37. package/build/VlcPlayerModule.d.ts.map +1 -0
  38. package/build/VlcPlayerModule.js +4 -0
  39. package/build/VlcPlayerModule.js.map +1 -0
  40. package/build/VlcPlayerView.d.ts +5 -0
  41. package/build/VlcPlayerView.d.ts.map +1 -0
  42. package/build/VlcPlayerView.js +36 -0
  43. package/build/VlcPlayerView.js.map +1 -0
  44. package/build/index.d.ts +4 -0
  45. package/build/index.d.ts.map +1 -0
  46. package/build/index.js +5 -0
  47. package/build/index.js.map +1 -0
  48. package/build/utils/props.d.ts +3 -0
  49. package/build/utils/props.d.ts.map +1 -0
  50. package/build/utils/props.js +11 -0
  51. package/build/utils/props.js.map +1 -0
  52. package/eslint.config.js +50 -0
  53. package/expo-module.config.json +16 -0
  54. package/ios/Enums/AudioMixingMode.swift +35 -0
  55. package/ios/ExpoLibVlcPlayer.podspec +29 -0
  56. package/ios/VlcPlayerManager.swift +116 -0
  57. package/ios/VlcPlayerModule.swift +110 -0
  58. package/ios/VlcPlayerView.swift +321 -0
  59. package/package.json +49 -0
  60. package/plugin/build/withExpoLibVlcPlayer.d.ts +3 -0
  61. package/plugin/build/withExpoLibVlcPlayer.js +18 -0
  62. package/plugin/src/withExpoLibVlcPlayer.ts +21 -0
  63. package/plugin/tsconfig.json +9 -0
  64. package/plugin/tsconfig.tsbuildinfo +1 -0
  65. package/src/VlcPlayer.types.ts +291 -0
  66. package/src/VlcPlayerModule.ts +7 -0
  67. package/src/VlcPlayerView.tsx +73 -0
  68. package/src/index.ts +4 -0
  69. package/src/utils/props.ts +20 -0
  70. package/tsconfig.json +9 -0
@@ -0,0 +1,291 @@
1
+ import * as React from "react";
2
+ import type { ViewProps } from "react-native";
3
+
4
+ export interface VLCPlayerViewRef {
5
+ /**
6
+ * Starts playback for the current player
7
+ *
8
+ * @returns void
9
+ */
10
+ readonly play: () => Promise<void>;
11
+ /**
12
+ * Pauses playback for the current player
13
+ *
14
+ * @returns void
15
+ */
16
+ readonly pause: () => Promise<void>;
17
+ /**
18
+ * Stops playback for the current player
19
+ *
20
+ * @returns void
21
+ */
22
+ readonly stop: () => Promise<void>;
23
+ /**
24
+ * Sets position of the current player
25
+ *
26
+ * @param position - Must be a float number between `0` and `1`
27
+ *
28
+ * @returns void
29
+ */
30
+ readonly seek: (position: number) => Promise<void>;
31
+ }
32
+
33
+ /**
34
+ * @hidden
35
+ */
36
+ export type BufferingListener = () => void;
37
+
38
+ /**
39
+ * @hidden
40
+ */
41
+ export type PlayingPausedListener = () => void;
42
+
43
+ /**
44
+ * @hidden
45
+ */
46
+ export type StoppedListener = () => void;
47
+
48
+ /**
49
+ * @hidden
50
+ */
51
+ export type EndedListener = () => void;
52
+
53
+ /**
54
+ * @hidden
55
+ */
56
+ export type RepeatListener = () => void;
57
+
58
+ /**
59
+ * @hidden
60
+ */
61
+ export type WarnListener = (event: { nativeEvent: Warn }) => void;
62
+
63
+ export type Warn = { warn: string };
64
+
65
+ /**
66
+ * @hidden
67
+ */
68
+ export type ErrorListener = (event: { nativeEvent: Error }) => void;
69
+
70
+ export type Error = { error: string };
71
+
72
+ /**
73
+ * @hidden
74
+ */
75
+ export type PositionChangedListener = (event: {
76
+ nativeEvent: PositionChanged;
77
+ }) => void;
78
+
79
+ export type PositionChanged = { position: number };
80
+
81
+ /**
82
+ * @hidden
83
+ */
84
+ export type LoadListener = (event: { nativeEvent: VideoInfo }) => void;
85
+
86
+ /**
87
+ * @hidden
88
+ */
89
+ export type BackgroundListener = () => void;
90
+
91
+ export interface Track {
92
+ id: number;
93
+ name: string;
94
+ }
95
+
96
+ export interface VideoTracks {
97
+ audio: Track[];
98
+ subtitle: Track[];
99
+ }
100
+
101
+ export interface VideoInfo {
102
+ width: number;
103
+ height: number;
104
+ aspectRatio: string | null;
105
+ duration: number;
106
+ tracks: VideoTracks;
107
+ seekable: boolean;
108
+ }
109
+
110
+ export interface Subtitle {
111
+ uri: string;
112
+ enable: boolean;
113
+ }
114
+
115
+ export interface TracksOptions {
116
+ audio: number;
117
+ subtitle: number;
118
+ }
119
+
120
+ /**
121
+ * @hidden
122
+ */
123
+ export interface VlcPlayerViewNativeProps {
124
+ ref?: React.Ref<VLCPlayerViewRef>;
125
+ uri?: string;
126
+ subtitle?: Subtitle;
127
+ options?: string[];
128
+ volume?: number;
129
+ mute?: boolean;
130
+ rate?: number;
131
+ tracks?: TracksOptions;
132
+ repeat?: boolean;
133
+ aspectRatio?: string;
134
+ audioMixingMode?: AudioMixingMode;
135
+ playInBackground?: boolean;
136
+ autoplay?: boolean;
137
+ onBuffering?: BufferingListener;
138
+ onPlaying?: PlayingPausedListener;
139
+ onPaused?: PlayingPausedListener;
140
+ onStopped?: StoppedListener;
141
+ onEnded?: EndedListener;
142
+ onRepeat?: RepeatListener;
143
+ onWarn?: WarnListener;
144
+ onError?: ErrorListener;
145
+ onPositionChanged?: PositionChangedListener;
146
+ onLoad?: LoadListener;
147
+ onBackground?: BackgroundListener;
148
+ }
149
+
150
+ export type AudioMixingMode =
151
+ | "mixWithOthers"
152
+ | "duckOthers"
153
+ | "auto"
154
+ | "doNotMix";
155
+
156
+ export interface VlcPlayerViewProps extends ViewProps {
157
+ /**
158
+ * Sets the URI of the media to be played
159
+ */
160
+ uri: string;
161
+ /**
162
+ * Sets subtitle URI and enabled state
163
+ *
164
+ * @example
165
+ * ```tsx
166
+ * <VLCPlayerView
167
+ * subtitle={{
168
+ * uri: "file://",
169
+ * enable: false,
170
+ * }}
171
+ * />
172
+ * ```
173
+ */
174
+ subtitle?: Subtitle;
175
+ /**
176
+ * https://wiki.videolan.org/VLC_command-line_help/
177
+ *
178
+ * Sets the VLC options to initialize the player with
179
+ *
180
+ * @example ["--network-caching=1000"]
181
+ *
182
+ * @default []
183
+ *
184
+ */
185
+ options?: string[];
186
+ /**
187
+ * Controls the player volume, must be an integer number between `0` and `100`
188
+ *
189
+ * @default 100
190
+ *
191
+ */
192
+ volume?: number;
193
+ /**
194
+ * Sets the player volume to `0`
195
+ */
196
+ mute?: boolean;
197
+ /**
198
+ * Controls the player rate, must be a float number
199
+ *
200
+ * @default 1
201
+ *
202
+ */
203
+ rate?: number;
204
+ /**
205
+ * Sets the player audio and subtitle tracks, see `VideoInfo` for tracks type
206
+ *
207
+ * @example
208
+ * ```tsx
209
+ * <VLCPlayerView
210
+ * tracks={{
211
+ * audio: 1,
212
+ * subtitle: 2,
213
+ * }}
214
+ * />
215
+ * ```
216
+ */
217
+ tracks?: TracksOptions;
218
+ /**
219
+ * Repeats media once playback is ended
220
+ */
221
+ repeat?: boolean;
222
+ /**
223
+ * Sets the player aspect ratio, must be a valid string
224
+ *
225
+ * @example "16:9"
226
+ */
227
+ aspectRatio?: string;
228
+ /**
229
+ * Determines how the player will interact with other audio playing in the system
230
+ *
231
+ * @default 'auto'
232
+ */
233
+ audioMixingMode?: AudioMixingMode;
234
+ /**
235
+ * Determines whether the player should continue playing after the app enters the background
236
+ *
237
+ * @default false
238
+ */
239
+ playInBackground?: boolean;
240
+ /**
241
+ * Autoplays media once player is created
242
+ *
243
+ * @default true
244
+ *
245
+ */
246
+ autoplay?: boolean;
247
+ /**
248
+ * Event that fires when player buffers
249
+ */
250
+ onBuffering?: () => void;
251
+ /**
252
+ * Event that fires when player plays
253
+ */
254
+ onPlaying?: () => void;
255
+ /**
256
+ * Event that fires when player pauses
257
+ */
258
+ onPaused?: () => void;
259
+ /**
260
+ * Event that fires when player stops
261
+ */
262
+ onStopped?: () => void;
263
+ /**
264
+ * Event that fires when player reaches an end
265
+ */
266
+ onEnded?: () => void;
267
+ /**
268
+ * Event that fires when player repeats
269
+ */
270
+ onRepeat?: () => void;
271
+ /**
272
+ * Event that fires when player emits a warning
273
+ */
274
+ onWarn?: (event: Warn) => void;
275
+ /**
276
+ * Event that fires when player encounters an error
277
+ */
278
+ onError?: (event: Error) => void;
279
+ /**
280
+ * Event that fires when player position changes
281
+ */
282
+ onPositionChanged?: (event: PositionChanged) => void;
283
+ /**
284
+ * Event that fires when player loads
285
+ */
286
+ onLoad?: (event: VideoInfo) => void;
287
+ /**
288
+ * Event that fires when player enters the background
289
+ */
290
+ onBackground?: () => void;
291
+ }
@@ -0,0 +1,7 @@
1
+ import { NativeModule, requireNativeModule } from "expo";
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
4
+ declare class VlcPlayerModule extends NativeModule<{}> {}
5
+
6
+ // This call loads the native module object from the JSI.
7
+ export default requireNativeModule<VlcPlayerModule>("ExpoLibVlcPlayer");
@@ -0,0 +1,73 @@
1
+ import { requireNativeView } from "expo";
2
+ import * as React from "react";
3
+
4
+ import {
5
+ VlcPlayerViewNativeProps,
6
+ VlcPlayerViewProps,
7
+ VLCPlayerViewRef,
8
+ type Warn,
9
+ type Error,
10
+ type PositionChanged,
11
+ type VideoInfo,
12
+ } from "./VlcPlayer.types";
13
+ import { convertNativeProps } from "./utils/props";
14
+
15
+ const NativeView: React.ComponentType<VlcPlayerViewNativeProps> =
16
+ requireNativeView("ExpoLibVlcPlayer");
17
+
18
+ let loggedRenderingChildrenWarning = false;
19
+
20
+ const VlcPlayerView = React.forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
21
+ (props, ref) => {
22
+ const nativeProps = convertNativeProps(props);
23
+
24
+ // @ts-expect-error
25
+ if (nativeProps.children && !loggedRenderingChildrenWarning) {
26
+ console.warn(
27
+ "The <VLCPlayerView> component does not support children. This may lead to inconsistent behaviour or crashes. If you want to render content on top of the VLCPlayer, consider using absolute positioning.",
28
+ );
29
+ loggedRenderingChildrenWarning = true;
30
+ }
31
+
32
+ const onWarn = ({ nativeEvent }: { nativeEvent: Warn }) => {
33
+ if (props.onWarn) {
34
+ props.onWarn(nativeEvent);
35
+ }
36
+ };
37
+
38
+ const onError = ({ nativeEvent }: { nativeEvent: Error }) => {
39
+ if (props.onError) {
40
+ props.onError(nativeEvent);
41
+ }
42
+ };
43
+
44
+ const onPositionChanged = ({
45
+ nativeEvent,
46
+ }: {
47
+ nativeEvent: PositionChanged;
48
+ }) => {
49
+ if (props.onPositionChanged) {
50
+ props.onPositionChanged(nativeEvent);
51
+ }
52
+ };
53
+
54
+ const onLoad = ({ nativeEvent }: { nativeEvent: VideoInfo }) => {
55
+ if (props.onLoad) {
56
+ props.onLoad(nativeEvent);
57
+ }
58
+ };
59
+
60
+ return (
61
+ <NativeView
62
+ {...nativeProps}
63
+ ref={ref}
64
+ onWarn={onWarn}
65
+ onError={onError}
66
+ onPositionChanged={onPositionChanged}
67
+ onLoad={onLoad}
68
+ />
69
+ );
70
+ },
71
+ );
72
+
73
+ export default VlcPlayerView;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Reexport the native module. On native platforms, it will be resolved to VlcPlayer.ts
2
+ export { default } from "./VlcPlayerModule";
3
+ export { default as VLCPlayerView } from "./VlcPlayerView";
4
+ export * from "./VlcPlayer.types";
@@ -0,0 +1,20 @@
1
+ import {
2
+ VlcPlayerViewNativeProps,
3
+ VlcPlayerViewProps,
4
+ } from "../VlcPlayer.types";
5
+
6
+ export function convertNativeProps(
7
+ props?: VlcPlayerViewProps,
8
+ ): VlcPlayerViewNativeProps {
9
+ if (!props || typeof props !== "object") {
10
+ return {};
11
+ }
12
+
13
+ const nativeProps: VlcPlayerViewNativeProps = {};
14
+
15
+ for (const [key, value] of Object.entries(props)) {
16
+ nativeProps[key as keyof VlcPlayerViewNativeProps] = value;
17
+ }
18
+
19
+ return nativeProps;
20
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ // @generated by expo-module-scripts
2
+ {
3
+ "extends": "expo-module-scripts/tsconfig.base",
4
+ "compilerOptions": {
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__rsc_tests__/*"]
9
+ }