expo-libvlc-player 0.1.7 → 0.1.9
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/.eslintrc.js +2 -0
- package/README.md +1 -2
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerManager.kt +2 -2
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerModule.kt +1 -3
- package/android/src/main/java/expo/modules/libvlcplayer/VlcPlayerView.kt +2 -5
- package/build/VlcPlayer.types.d.ts +291 -0
- package/build/VlcPlayer.types.d.ts.map +1 -0
- package/build/VlcPlayer.types.js +2 -0
- package/build/VlcPlayer.types.js.map +1 -0
- package/build/VlcPlayerModule.d.ts +6 -0
- package/build/VlcPlayerModule.d.ts.map +1 -0
- package/build/VlcPlayerModule.js +4 -0
- package/build/VlcPlayerModule.js.map +1 -0
- package/build/VlcPlayerView.d.ts +4 -0
- package/build/VlcPlayerView.d.ts.map +1 -0
- package/build/VlcPlayerView.js +41 -0
- package/build/VlcPlayerView.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -0
- package/build/utils/props.d.ts +3 -0
- package/build/utils/props.d.ts.map +1 -0
- package/build/utils/props.js +13 -0
- package/build/utils/props.js.map +1 -0
- package/ios/VlcPlayerManager.swift +6 -3
- package/ios/VlcPlayerModule.swift +5 -3
- package/ios/VlcPlayerView.swift +2 -5
- package/lint-staged.config.js +4 -0
- package/package.json +2 -8
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/src/VlcPlayer.types.ts +11 -16
- package/src/VlcPlayerView.tsx +8 -8
package/.eslintrc.js
ADDED
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ The `VLCPlayerView` extends React Native `ViewProps` and implements its own:
|
|
|
113
113
|
| ------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
114
114
|
| `onBuffering` | Called after the `Buffering` player event | |
|
|
115
115
|
| `onPlaying` | Called after the `Playing` player event | |
|
|
116
|
-
| `onPaused` | Called after the `Paused` player event |
|
|
116
|
+
| `onPaused` | Called after the `Paused` player event | `{ background: boolean }` |
|
|
117
117
|
| `onStopped` | Called after the `Stopped` player event | |
|
|
118
118
|
| `onPositionChanged` | Called after the `PositionChanged` player event | `{ position: number }` |
|
|
119
119
|
| `onEnded` | Called after the `EndReached` player event | |
|
|
@@ -121,7 +121,6 @@ The `VLCPlayerView` extends React Native `ViewProps` and implements its own:
|
|
|
121
121
|
| `onWarn` | Called after the player encounters a conflict | `{ warn: string }` |
|
|
122
122
|
| `onError` | Called after the `EncounteredError` player event | `{ error: string }` |
|
|
123
123
|
| `onLoad` | Called after the `Buffering` player event | `{ width: number, height: number, aspectRatio: string, duration: number, tracks: object, seekable: boolean }` |
|
|
124
|
-
| `onBackground` | Called after the player enters the background | `{ background: boolean }` |
|
|
125
124
|
|
|
126
125
|
## Disclaimer
|
|
127
126
|
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'expo.modules.libvlcplayer'
|
|
4
|
-
version = '0.1.
|
|
4
|
+
version = '0.1.8'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -35,7 +35,7 @@ android {
|
|
|
35
35
|
namespace "expo.modules.libvlcplayer"
|
|
36
36
|
defaultConfig {
|
|
37
37
|
versionCode 1
|
|
38
|
-
versionName "0.1.
|
|
38
|
+
versionName "0.1.8"
|
|
39
39
|
consumerProguardFiles("proguard-rules.pro")
|
|
40
40
|
}
|
|
41
41
|
lintOptions {
|
|
@@ -43,6 +43,8 @@ object VlcPlayerManager {
|
|
|
43
43
|
fun onAppForegrounded() {
|
|
44
44
|
views.forEach { playerView ->
|
|
45
45
|
playerView.get()?.let { view ->
|
|
46
|
+
view.isBackgrounded = false
|
|
47
|
+
|
|
46
48
|
view.mediaPlayer?.let { player ->
|
|
47
49
|
player.attachViews(
|
|
48
50
|
view.videoLayout,
|
|
@@ -68,8 +70,6 @@ object VlcPlayerManager {
|
|
|
68
70
|
views.forEach { playerView ->
|
|
69
71
|
playerView.get()?.let { view ->
|
|
70
72
|
view.isBackgrounded = true
|
|
71
|
-
val background = mapOf("background" to view.isBackgrounded)
|
|
72
|
-
view.onBackground(background)
|
|
73
73
|
|
|
74
74
|
view.mediaPlayer?.let { player ->
|
|
75
75
|
if (view.playInBackground != true && player.isPlaying()) {
|
|
@@ -17,7 +17,6 @@ private const val WARN_EVENT = "onWarn"
|
|
|
17
17
|
private const val ERROR_EVENT = "onError"
|
|
18
18
|
private const val POSITION_CHANGED_EVENT = "onPositionChanged"
|
|
19
19
|
private const val LOAD_EVENT = "onLoad"
|
|
20
|
-
private const val BACKGROUND_EVENT = "onBackground"
|
|
21
20
|
|
|
22
21
|
val playerEvents = arrayOf(
|
|
23
22
|
BUFFERING_EVENT,
|
|
@@ -29,8 +28,7 @@ val playerEvents = arrayOf(
|
|
|
29
28
|
WARN_EVENT,
|
|
30
29
|
ERROR_EVENT,
|
|
31
30
|
POSITION_CHANGED_EVENT,
|
|
32
|
-
LOAD_EVENT
|
|
33
|
-
BACKGROUND_EVENT
|
|
31
|
+
LOAD_EVENT
|
|
34
32
|
)
|
|
35
33
|
|
|
36
34
|
class VlcPlayerModule : Module() {
|
|
@@ -62,7 +62,6 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
62
62
|
private val onError by EventDispatcher()
|
|
63
63
|
private val onPositionChanged by EventDispatcher()
|
|
64
64
|
private val onLoad by EventDispatcher<WritableMap>()
|
|
65
|
-
internal val onBackground by EventDispatcher()
|
|
66
65
|
|
|
67
66
|
private lateinit var audioFocusManager: AudioFocusManager
|
|
68
67
|
|
|
@@ -163,7 +162,8 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
Event.Paused -> {
|
|
166
|
-
|
|
165
|
+
val background = mapOf("background" to isBackgrounded)
|
|
166
|
+
onPaused(background)
|
|
167
167
|
audioFocusManager.updateAudioFocus()
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -333,9 +333,6 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
fun play() {
|
|
336
|
-
isBackgrounded = false
|
|
337
|
-
val background = mapOf("background" to isBackgrounded)
|
|
338
|
-
onBackground(background)
|
|
339
336
|
mediaPlayer?.play()
|
|
340
337
|
}
|
|
341
338
|
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import type { ViewProps } from "react-native";
|
|
2
|
+
export interface VLCPlayerViewRef {
|
|
3
|
+
/**
|
|
4
|
+
* Starts playback for the current player
|
|
5
|
+
*
|
|
6
|
+
* @returns A promise which resolves to `void`
|
|
7
|
+
*/
|
|
8
|
+
readonly play: () => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Pauses playback for the current player
|
|
11
|
+
*
|
|
12
|
+
* @returns A promise which resolves to `void`
|
|
13
|
+
*/
|
|
14
|
+
readonly pause: () => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Stops playback for the current player
|
|
17
|
+
*
|
|
18
|
+
* @returns A promise which resolves to `void`
|
|
19
|
+
*/
|
|
20
|
+
readonly stop: () => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Sets position of the current player
|
|
23
|
+
*
|
|
24
|
+
* @param position - Must be a float number between `0` and `1`
|
|
25
|
+
*
|
|
26
|
+
* @returns void
|
|
27
|
+
*/
|
|
28
|
+
readonly seek: (position: number) => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
export type BufferingListener = () => void;
|
|
34
|
+
/**
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
37
|
+
export type PlayingListener = () => void;
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
export type PausedListener = (event: {
|
|
42
|
+
nativeEvent: Paused;
|
|
43
|
+
}) => void;
|
|
44
|
+
export type Paused = {
|
|
45
|
+
background: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
export type StoppedListener = () => void;
|
|
51
|
+
/**
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
export type EndedListener = () => void;
|
|
55
|
+
/**
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
export type RepeatListener = () => void;
|
|
59
|
+
/**
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
export type WarnListener = (event: {
|
|
63
|
+
nativeEvent: Warn;
|
|
64
|
+
}) => void;
|
|
65
|
+
export type Warn = {
|
|
66
|
+
warn: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
71
|
+
export type ErrorListener = (event: {
|
|
72
|
+
nativeEvent: Error;
|
|
73
|
+
}) => void;
|
|
74
|
+
export type Error = {
|
|
75
|
+
error: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @hidden
|
|
79
|
+
*/
|
|
80
|
+
export type PositionChangedListener = (event: {
|
|
81
|
+
nativeEvent: PositionChanged;
|
|
82
|
+
}) => void;
|
|
83
|
+
export type PositionChanged = {
|
|
84
|
+
position: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* @hidden
|
|
88
|
+
*/
|
|
89
|
+
export type LoadListener = (event: {
|
|
90
|
+
nativeEvent: VideoInfo;
|
|
91
|
+
}) => void;
|
|
92
|
+
export interface Track {
|
|
93
|
+
id: number;
|
|
94
|
+
name: string;
|
|
95
|
+
}
|
|
96
|
+
export interface VideoTracks {
|
|
97
|
+
audio: Track[];
|
|
98
|
+
subtitle: Track[];
|
|
99
|
+
}
|
|
100
|
+
export interface VideoInfo {
|
|
101
|
+
width: number;
|
|
102
|
+
height: number;
|
|
103
|
+
aspectRatio: string | null;
|
|
104
|
+
duration: number;
|
|
105
|
+
tracks: VideoTracks;
|
|
106
|
+
seekable: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface Subtitle {
|
|
109
|
+
uri: string;
|
|
110
|
+
enable: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface TracksOptions {
|
|
113
|
+
audio: number;
|
|
114
|
+
subtitle: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @hidden
|
|
118
|
+
*/
|
|
119
|
+
export interface VlcPlayerViewNativeProps {
|
|
120
|
+
ref?: React.Ref<VLCPlayerViewRef>;
|
|
121
|
+
uri?: string;
|
|
122
|
+
subtitle?: Subtitle;
|
|
123
|
+
options?: string[];
|
|
124
|
+
volume?: number;
|
|
125
|
+
mute?: boolean;
|
|
126
|
+
rate?: number;
|
|
127
|
+
tracks?: TracksOptions;
|
|
128
|
+
time?: number;
|
|
129
|
+
repeat?: boolean;
|
|
130
|
+
aspectRatio?: string;
|
|
131
|
+
audioMixingMode?: AudioMixingMode;
|
|
132
|
+
playInBackground?: boolean;
|
|
133
|
+
autoplay?: boolean;
|
|
134
|
+
onBuffering?: BufferingListener;
|
|
135
|
+
onPlaying?: PlayingListener;
|
|
136
|
+
onPaused?: PausedListener;
|
|
137
|
+
onStopped?: StoppedListener;
|
|
138
|
+
onEnded?: EndedListener;
|
|
139
|
+
onRepeat?: RepeatListener;
|
|
140
|
+
onWarn?: WarnListener;
|
|
141
|
+
onError?: ErrorListener;
|
|
142
|
+
onPositionChanged?: PositionChangedListener;
|
|
143
|
+
onLoad?: LoadListener;
|
|
144
|
+
}
|
|
145
|
+
export type AudioMixingMode = "mixWithOthers" | "duckOthers" | "auto" | "doNotMix";
|
|
146
|
+
export interface VlcPlayerViewProps extends ViewProps {
|
|
147
|
+
/**
|
|
148
|
+
* Sets the URI of the media to be played
|
|
149
|
+
*/
|
|
150
|
+
uri: string;
|
|
151
|
+
/**
|
|
152
|
+
* Sets subtitle URI and enabled state
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* <VLCPlayerView
|
|
157
|
+
* subtitle={{
|
|
158
|
+
* uri: "file://",
|
|
159
|
+
* enable: false,
|
|
160
|
+
* }}
|
|
161
|
+
* />
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
subtitle?: Subtitle;
|
|
165
|
+
/**
|
|
166
|
+
* https://wiki.videolan.org/VLC_command-line_help/
|
|
167
|
+
*
|
|
168
|
+
* Sets the VLC options to initialize the player with
|
|
169
|
+
*
|
|
170
|
+
* @example ["--network-caching=1000"]
|
|
171
|
+
*
|
|
172
|
+
* @default []
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
options?: string[];
|
|
176
|
+
/**
|
|
177
|
+
* Controls the player volume. Must be an integer number between `0` and `100`
|
|
178
|
+
*
|
|
179
|
+
* @default 100
|
|
180
|
+
*
|
|
181
|
+
*/
|
|
182
|
+
volume?: number;
|
|
183
|
+
/**
|
|
184
|
+
* Sets the player volume to `0`
|
|
185
|
+
*
|
|
186
|
+
* @default false
|
|
187
|
+
*
|
|
188
|
+
*/
|
|
189
|
+
mute?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Controls the player rate. Must be a float number
|
|
192
|
+
*
|
|
193
|
+
* @default 1
|
|
194
|
+
*
|
|
195
|
+
*/
|
|
196
|
+
rate?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Sets the player audio and subtitle tracks, see `VideoInfo` for tracks type
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```tsx
|
|
202
|
+
* <VLCPlayerView
|
|
203
|
+
* tracks={{
|
|
204
|
+
* audio: 1,
|
|
205
|
+
* subtitle: 2,
|
|
206
|
+
* }}
|
|
207
|
+
* />
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
tracks?: TracksOptions;
|
|
211
|
+
/**
|
|
212
|
+
* Controls the player time once created. Must be an integer number in milliseconds
|
|
213
|
+
*
|
|
214
|
+
* @default 0
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
time?: number;
|
|
218
|
+
/**
|
|
219
|
+
* Repeats media once playback is ended
|
|
220
|
+
*
|
|
221
|
+
* @default false
|
|
222
|
+
*
|
|
223
|
+
*/
|
|
224
|
+
repeat?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Sets the player aspect ratio. Must be a valid string
|
|
227
|
+
*
|
|
228
|
+
* @example "16:9"
|
|
229
|
+
*/
|
|
230
|
+
aspectRatio?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Determines how the player will interact with other audio playing in the system
|
|
233
|
+
*
|
|
234
|
+
* @default "auto"
|
|
235
|
+
*/
|
|
236
|
+
audioMixingMode?: AudioMixingMode;
|
|
237
|
+
/**
|
|
238
|
+
* Determines whether the player should continue playing after the app enters the background
|
|
239
|
+
*
|
|
240
|
+
* @default false
|
|
241
|
+
*/
|
|
242
|
+
playInBackground?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Autoplays media once player is created
|
|
245
|
+
*
|
|
246
|
+
* @default true
|
|
247
|
+
*
|
|
248
|
+
*/
|
|
249
|
+
autoplay?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Event that fires when player buffers
|
|
252
|
+
*/
|
|
253
|
+
onBuffering?: () => void;
|
|
254
|
+
/**
|
|
255
|
+
* Event that fires when player plays
|
|
256
|
+
*/
|
|
257
|
+
onPlaying?: () => void;
|
|
258
|
+
/**
|
|
259
|
+
* Event that fires when player pauses
|
|
260
|
+
*/
|
|
261
|
+
onPaused?: (event: Paused) => void;
|
|
262
|
+
/**
|
|
263
|
+
* Event that fires when player stops
|
|
264
|
+
*/
|
|
265
|
+
onStopped?: () => void;
|
|
266
|
+
/**
|
|
267
|
+
* Event that fires when player reaches an end
|
|
268
|
+
*/
|
|
269
|
+
onEnded?: () => void;
|
|
270
|
+
/**
|
|
271
|
+
* Event that fires when player repeats
|
|
272
|
+
*/
|
|
273
|
+
onRepeat?: () => void;
|
|
274
|
+
/**
|
|
275
|
+
* Event that fires when player emits a warning
|
|
276
|
+
*/
|
|
277
|
+
onWarn?: (event: Warn) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Event that fires when player encounters an error
|
|
280
|
+
*/
|
|
281
|
+
onError?: (event: Error) => void;
|
|
282
|
+
/**
|
|
283
|
+
* Event that fires when player position changes
|
|
284
|
+
*/
|
|
285
|
+
onPositionChanged?: (event: PositionChanged) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Event that fires when player loads
|
|
288
|
+
*/
|
|
289
|
+
onLoad?: (event: VideoInfo) => void;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=VlcPlayer.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VlcPlayer.types.d.ts","sourceRoot":"","sources":["../src/VlcPlayer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,IAAI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SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VlcPlayer.types.js","sourceRoot":"","sources":["../src/VlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nexport interface VLCPlayerViewRef {\n /**\n * Starts playback for the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback for the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback for the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly stop: () => Promise<void>;\n /**\n * Sets position of the current player\n *\n * @param position - Must be a float number between `0` and `1`\n *\n * @returns void\n */\n readonly seek: (position: number) => Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport type BufferingListener = () => void;\n\n/**\n * @hidden\n */\nexport type PlayingListener = () => void;\n\n/**\n * @hidden\n */\nexport type PausedListener = (event: { nativeEvent: Paused }) => void;\n\nexport type Paused = { background: boolean };\n\n/**\n * @hidden\n */\nexport type StoppedListener = () => void;\n\n/**\n * @hidden\n */\nexport type EndedListener = () => void;\n\n/**\n * @hidden\n */\nexport type RepeatListener = () => void;\n\n/**\n * @hidden\n */\nexport type WarnListener = (event: { nativeEvent: Warn }) => void;\n\nexport type Warn = { warn: string };\n\n/**\n * @hidden\n */\nexport type ErrorListener = (event: { nativeEvent: Error }) => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\nexport type PositionChangedListener = (event: {\n nativeEvent: PositionChanged;\n}) => void;\n\nexport type PositionChanged = { position: number };\n\n/**\n * @hidden\n */\nexport type LoadListener = (event: { nativeEvent: VideoInfo }) => void;\n\nexport interface Track {\n id: number;\n name: string;\n}\n\nexport interface VideoTracks {\n audio: Track[];\n subtitle: Track[];\n}\n\nexport interface VideoInfo {\n width: number;\n height: number;\n aspectRatio: string | null;\n duration: number;\n tracks: VideoTracks;\n seekable: boolean;\n}\n\nexport interface Subtitle {\n uri: string;\n enable: boolean;\n}\n\nexport interface TracksOptions {\n audio: number;\n subtitle: number;\n}\n\n/**\n * @hidden\n */\nexport interface VlcPlayerViewNativeProps {\n ref?: React.Ref<VLCPlayerViewRef>;\n uri?: string;\n subtitle?: Subtitle;\n options?: string[];\n volume?: number;\n mute?: boolean;\n rate?: number;\n tracks?: TracksOptions;\n time?: number;\n repeat?: boolean;\n aspectRatio?: string;\n audioMixingMode?: AudioMixingMode;\n playInBackground?: boolean;\n autoplay?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEnded?: EndedListener;\n onRepeat?: RepeatListener;\n onWarn?: WarnListener;\n onError?: ErrorListener;\n onPositionChanged?: PositionChangedListener;\n onLoad?: LoadListener;\n}\n\nexport type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"doNotMix\";\n\nexport interface VlcPlayerViewProps extends ViewProps {\n /**\n * Sets the URI of the media to be played\n */\n uri: string;\n /**\n * Sets subtitle URI and enabled state\n *\n * @example\n * ```tsx\n * <VLCPlayerView\n * subtitle={{\n * uri: \"file://\",\n * enable: false,\n * }}\n * />\n * ```\n */\n subtitle?: Subtitle;\n /**\n * https://wiki.videolan.org/VLC_command-line_help/\n *\n * Sets the VLC options to initialize the player with\n *\n * @example [\"--network-caching=1000\"]\n *\n * @default []\n *\n */\n options?: string[];\n /**\n * Controls the player volume. Must be an integer number between `0` and `100`\n *\n * @default 100\n *\n */\n volume?: number;\n /**\n * Sets the player volume to `0`\n *\n * @default false\n *\n */\n mute?: boolean;\n /**\n * Controls the player rate. Must be a float number\n *\n * @default 1\n *\n */\n rate?: number;\n /**\n * Sets the player audio and subtitle tracks, see `VideoInfo` for tracks type\n *\n * @example\n * ```tsx\n * <VLCPlayerView\n * tracks={{\n * audio: 1,\n * subtitle: 2,\n * }}\n * />\n * ```\n */\n tracks?: TracksOptions;\n /**\n * Controls the player time once created. Must be an integer number in milliseconds\n *\n * @default 0\n *\n */\n time?: number;\n /**\n * Repeats media once playback is ended\n *\n * @default false\n *\n */\n repeat?: boolean;\n /**\n * Sets the player aspect ratio. Must be a valid string\n *\n * @example \"16:9\"\n */\n aspectRatio?: string;\n /**\n * Determines how the player will interact with other audio playing in the system\n *\n * @default \"auto\"\n */\n audioMixingMode?: AudioMixingMode;\n /**\n * Determines whether the player should continue playing after the app enters the background\n *\n * @default false\n */\n playInBackground?: boolean;\n /**\n * Autoplays media once player is created\n *\n * @default true\n *\n */\n autoplay?: boolean;\n /**\n * Event that fires when player buffers\n */\n onBuffering?: () => void;\n /**\n * Event that fires when player plays\n */\n onPlaying?: () => void;\n /**\n * Event that fires when player pauses\n */\n onPaused?: (event: Paused) => void;\n /**\n * Event that fires when player stops\n */\n onStopped?: () => void;\n /**\n * Event that fires when player reaches an end\n */\n onEnded?: () => void;\n /**\n * Event that fires when player repeats\n */\n onRepeat?: () => void;\n /**\n * Event that fires when player emits a warning\n */\n onWarn?: (event: Warn) => void;\n /**\n * Event that fires when player encounters an error\n */\n onError?: (event: Error) => void;\n /**\n * Event that fires when player position changes\n */\n onPositionChanged?: (event: PositionChanged) => void;\n /**\n * Event that fires when player loads\n */\n onLoad?: (event: VideoInfo) => void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VlcPlayerModule.d.ts","sourceRoot":"","sources":["../src/VlcPlayerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAGzD,OAAO,OAAO,eAAgB,SAAQ,YAAY,CAAC,EAAE,CAAC;CAAG;;AAGzD,wBAAwE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VlcPlayerModule.js","sourceRoot":"","sources":["../src/VlcPlayerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAKzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAkB,kBAAkB,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ndeclare class VlcPlayerModule extends NativeModule<{}> {}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<VlcPlayerModule>(\"ExpoLibVlcPlayer\");\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { VlcPlayerViewProps, VLCPlayerViewRef } from "./VlcPlayer.types";
|
|
2
|
+
declare const VlcPlayerView: import("react").ForwardRefExoticComponent<VlcPlayerViewProps & import("react").RefAttributes<VLCPlayerViewRef>>;
|
|
3
|
+
export default VlcPlayerView;
|
|
4
|
+
//# sourceMappingURL=VlcPlayerView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VlcPlayerView.d.ts","sourceRoot":"","sources":["../src/VlcPlayerView.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAMjB,MAAM,mBAAmB,CAAC;AAQ3B,QAAA,MAAM,aAAa,iHA0DlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { requireNativeView } from "expo";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { convertNativeProps } from "./utils/props";
|
|
4
|
+
const NativeView = requireNativeView("ExpoLibVlcPlayer");
|
|
5
|
+
let loggedRenderingChildrenWarning = false;
|
|
6
|
+
const VlcPlayerView = forwardRef((props, ref) => {
|
|
7
|
+
const nativeProps = convertNativeProps(props);
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
if (nativeProps.children && !loggedRenderingChildrenWarning) {
|
|
10
|
+
console.warn("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.");
|
|
11
|
+
loggedRenderingChildrenWarning = true;
|
|
12
|
+
}
|
|
13
|
+
const onPaused = ({ nativeEvent }) => {
|
|
14
|
+
if (props.onPaused) {
|
|
15
|
+
props.onPaused(nativeEvent);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const onWarn = ({ nativeEvent }) => {
|
|
19
|
+
if (props.onWarn) {
|
|
20
|
+
props.onWarn(nativeEvent);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const onError = ({ nativeEvent }) => {
|
|
24
|
+
if (props.onError) {
|
|
25
|
+
props.onError(nativeEvent);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const onPositionChanged = ({ nativeEvent, }) => {
|
|
29
|
+
if (props.onPositionChanged) {
|
|
30
|
+
props.onPositionChanged(nativeEvent);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const onLoad = ({ nativeEvent }) => {
|
|
34
|
+
if (props.onLoad) {
|
|
35
|
+
props.onLoad(nativeEvent);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return (<NativeView {...nativeProps} ref={ref} onPaused={onPaused} onWarn={onWarn} onError={onError} onPositionChanged={onPositionChanged} onLoad={onLoad}/>);
|
|
39
|
+
});
|
|
40
|
+
export default VlcPlayerView;
|
|
41
|
+
//# sourceMappingURL=VlcPlayerView.js.map
|
|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AAG,CAAC,EACzB,WAAW,GAGZ,EAAE,EAAE;QACH,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,EAAE,WAAW,EAA8B,EAAE,EAAE;QAC7D,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,UAAU,CACT,IAAI,WAAW,CAAC,CAChB,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,MAAM,CAAC,CAAC,MAAM,CAAC,EACf,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { requireNativeView } from \"expo\";\nimport { forwardRef, type ComponentType } from \"react\";\n\nimport {\n VlcPlayerViewNativeProps,\n VlcPlayerViewProps,\n VLCPlayerViewRef,\n type Paused,\n type Warn,\n type Error,\n type PositionChanged,\n type VideoInfo,\n} from \"./VlcPlayer.types\";\nimport { convertNativeProps } from \"./utils/props\";\n\nconst NativeView: ComponentType<VlcPlayerViewNativeProps> =\n requireNativeView(\"ExpoLibVlcPlayer\");\n\nlet loggedRenderingChildrenWarning = false;\n\nconst VlcPlayerView = forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(\n (props, ref) => {\n const nativeProps = convertNativeProps(props);\n\n // @ts-expect-error\n if (nativeProps.children && !loggedRenderingChildrenWarning) {\n console.warn(\n \"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.\",\n );\n loggedRenderingChildrenWarning = true;\n }\n\n const onPaused = ({ nativeEvent }: { nativeEvent: Paused }) => {\n if (props.onPaused) {\n props.onPaused(nativeEvent);\n }\n };\n\n const onWarn = ({ nativeEvent }: { nativeEvent: Warn }) => {\n if (props.onWarn) {\n props.onWarn(nativeEvent);\n }\n };\n\n const onError = ({ nativeEvent }: { nativeEvent: Error }) => {\n if (props.onError) {\n props.onError(nativeEvent);\n }\n };\n\n const onPositionChanged = ({\n nativeEvent,\n }: {\n nativeEvent: PositionChanged;\n }) => {\n if (props.onPositionChanged) {\n props.onPositionChanged(nativeEvent);\n }\n };\n\n const onLoad = ({ nativeEvent }: { nativeEvent: VideoInfo }) => {\n if (props.onLoad) {\n props.onLoad(nativeEvent);\n }\n };\n\n return (\n <NativeView\n {...nativeProps}\n ref={ref}\n onPaused={onPaused}\n onWarn={onWarn}\n onError={onError}\n onPositionChanged={onPositionChanged}\n onLoad={onLoad}\n />\n );\n },\n);\n\nexport default VlcPlayerView;\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,mBAAmB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Reexport the native module. On native platforms, it will be resolved to VlcPlayerModule.ts
|
|
2
|
+
export { default } from "./VlcPlayerModule";
|
|
3
|
+
export { default as VLCPlayerView } from "./VlcPlayerView";
|
|
4
|
+
export * from "./VlcPlayer.types";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,mBAAmB,CAAC","sourcesContent":["// Reexport the native module. On native platforms, it will be resolved to VlcPlayerModule.ts\nexport { default } from \"./VlcPlayerModule\";\nexport { default as VLCPlayerView } from \"./VlcPlayerView\";\nexport * from \"./VlcPlayer.types\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/utils/props.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,EAAE,kBAAkB,GACzB,wBAAwB,CAc1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function convertNativeProps(props) {
|
|
2
|
+
if (!props || typeof props !== "object") {
|
|
3
|
+
return {};
|
|
4
|
+
}
|
|
5
|
+
const nativeProps = {};
|
|
6
|
+
for (const [key, value] of Object.entries(props)) {
|
|
7
|
+
if (key in {}) {
|
|
8
|
+
nativeProps[key] = value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return nativeProps;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/utils/props.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,kBAAkB,CAChC,KAA0B;IAE1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,WAAW,GAA6B,EAAE,CAAC;IAEjD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,GAAG,IAAK,EAA+B,EAAE,CAAC;YAC3C,WAAmB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import {\n VlcPlayerViewNativeProps,\n VlcPlayerViewProps,\n} from \"../VlcPlayer.types\";\n\nexport function convertNativeProps(\n props?: VlcPlayerViewProps,\n): VlcPlayerViewNativeProps {\n if (!props || typeof props !== \"object\") {\n return {};\n }\n\n const nativeProps: VlcPlayerViewNativeProps = {};\n\n for (const [key, value] of Object.entries(props)) {\n if (key in ({} as VlcPlayerViewNativeProps)) {\n (nativeProps as any)[key] = value;\n }\n }\n\n return nativeProps;\n}\n"]}
|
|
@@ -22,12 +22,15 @@ class VlcPlayerManager {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
func onAppForegrounded() {
|
|
26
|
+
for view in views.allObjects {
|
|
27
|
+
view.isBackgrounded = false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
func onAppBackgrounded() {
|
|
26
32
|
for view in views.allObjects {
|
|
27
33
|
view.isBackgrounded = true
|
|
28
|
-
let background = ["background": view.isBackgrounded]
|
|
29
|
-
view.onBackground(background)
|
|
30
|
-
view.onBackground([:])
|
|
31
34
|
|
|
32
35
|
guard let player = view.mediaPlayer else { continue }
|
|
33
36
|
|
|
@@ -11,7 +11,6 @@ private let warnEvent = "onWarn"
|
|
|
11
11
|
private let errorEvent = "onError"
|
|
12
12
|
private let positionChangedEvent = "onPositionChanged"
|
|
13
13
|
private let loadEvent = "onLoad"
|
|
14
|
-
private let backgroundEvent = "onBackground"
|
|
15
14
|
|
|
16
15
|
let playerEvents = [
|
|
17
16
|
bufferingEvent,
|
|
@@ -23,8 +22,7 @@ let playerEvents = [
|
|
|
23
22
|
warnEvent,
|
|
24
23
|
errorEvent,
|
|
25
24
|
positionChangedEvent,
|
|
26
|
-
loadEvent
|
|
27
|
-
backgroundEvent,
|
|
25
|
+
loadEvent
|
|
28
26
|
]
|
|
29
27
|
|
|
30
28
|
public class VlcPlayerModule: Module {
|
|
@@ -111,6 +109,10 @@ public class VlcPlayerModule: Module {
|
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
|
|
112
|
+
OnAppEntersForeground {
|
|
113
|
+
VlcPlayerManager.shared.onAppForegrounded()
|
|
114
|
+
}
|
|
115
|
+
|
|
114
116
|
OnAppEntersBackground {
|
|
115
117
|
VlcPlayerManager.shared.onAppBackgrounded()
|
|
116
118
|
}
|
package/ios/VlcPlayerView.swift
CHANGED
|
@@ -37,7 +37,6 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
37
37
|
private let onError = EventDispatcher()
|
|
38
38
|
private let onPositionChanged = EventDispatcher()
|
|
39
39
|
private let onLoad = EventDispatcher()
|
|
40
|
-
let onBackground = EventDispatcher()
|
|
41
40
|
|
|
42
41
|
required init(appContext: AppContext? = nil) {
|
|
43
42
|
super.init(appContext: appContext)
|
|
@@ -169,7 +168,8 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
169
168
|
}
|
|
170
169
|
}
|
|
171
170
|
case .paused:
|
|
172
|
-
|
|
171
|
+
let background = ["background": isBackgrounded]
|
|
172
|
+
onPaused(background)
|
|
173
173
|
VlcPlayerManager.shared.setAppropriateAudioSessionOrWarn()
|
|
174
174
|
case .stopped:
|
|
175
175
|
onStopped([:])
|
|
@@ -312,9 +312,6 @@ class VlcPlayerView: ExpoView, VLCMediaPlayerDelegate {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
func play() {
|
|
315
|
-
isBackgrounded = false
|
|
316
|
-
let background = ["background": isBackgrounded]
|
|
317
|
-
onBackground(background)
|
|
318
315
|
mediaPlayer?.play()
|
|
319
316
|
}
|
|
320
317
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-libvlc-player",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "LibVLC Player for Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -9,18 +9,12 @@
|
|
|
9
9
|
"clean": "expo-module clean",
|
|
10
10
|
"lint": "expo-module lint",
|
|
11
11
|
"test": "expo-module test",
|
|
12
|
-
"prepare": "husky",
|
|
12
|
+
"prepare": "husky && expo-module prepare",
|
|
13
13
|
"prepublishOnly": "expo-module prepublishOnly",
|
|
14
14
|
"expo-module": "expo-module",
|
|
15
15
|
"open:ios": "xed example/ios",
|
|
16
16
|
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
17
|
},
|
|
18
|
-
"lint-staged": {
|
|
19
|
-
"**/*.{ts,tsx,d.ts}": [
|
|
20
|
-
"eslint --fix",
|
|
21
|
-
"tsc --noEmit --skipLibCheck --jsx preserve"
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
18
|
"keywords": [
|
|
25
19
|
"react-native",
|
|
26
20
|
"vlc",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/withExpoLibVlcPlayer.ts"],"version":"5.8.3"}
|
package/src/VlcPlayer.types.ts
CHANGED
|
@@ -37,7 +37,14 @@ export type BufferingListener = () => void;
|
|
|
37
37
|
/**
|
|
38
38
|
* @hidden
|
|
39
39
|
*/
|
|
40
|
-
export type
|
|
40
|
+
export type PlayingListener = () => void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
export type PausedListener = (event: { nativeEvent: Paused }) => void;
|
|
46
|
+
|
|
47
|
+
export type Paused = { background: boolean };
|
|
41
48
|
|
|
42
49
|
/**
|
|
43
50
|
* @hidden
|
|
@@ -82,13 +89,6 @@ export type PositionChanged = { position: number };
|
|
|
82
89
|
*/
|
|
83
90
|
export type LoadListener = (event: { nativeEvent: VideoInfo }) => void;
|
|
84
91
|
|
|
85
|
-
/**
|
|
86
|
-
* @hidden
|
|
87
|
-
*/
|
|
88
|
-
export type BackgroundListener = (event: { nativeEvent: Background }) => void;
|
|
89
|
-
|
|
90
|
-
export type Background = { background: boolean };
|
|
91
|
-
|
|
92
92
|
export interface Track {
|
|
93
93
|
id: number;
|
|
94
94
|
name: string;
|
|
@@ -137,8 +137,8 @@ export interface VlcPlayerViewNativeProps {
|
|
|
137
137
|
playInBackground?: boolean;
|
|
138
138
|
autoplay?: boolean;
|
|
139
139
|
onBuffering?: BufferingListener;
|
|
140
|
-
onPlaying?:
|
|
141
|
-
onPaused?:
|
|
140
|
+
onPlaying?: PlayingListener;
|
|
141
|
+
onPaused?: PausedListener;
|
|
142
142
|
onStopped?: StoppedListener;
|
|
143
143
|
onEnded?: EndedListener;
|
|
144
144
|
onRepeat?: RepeatListener;
|
|
@@ -146,7 +146,6 @@ export interface VlcPlayerViewNativeProps {
|
|
|
146
146
|
onError?: ErrorListener;
|
|
147
147
|
onPositionChanged?: PositionChangedListener;
|
|
148
148
|
onLoad?: LoadListener;
|
|
149
|
-
onBackground?: BackgroundListener;
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
export type AudioMixingMode =
|
|
@@ -270,7 +269,7 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
270
269
|
/**
|
|
271
270
|
* Event that fires when player pauses
|
|
272
271
|
*/
|
|
273
|
-
onPaused?: () => void;
|
|
272
|
+
onPaused?: (event: Paused) => void;
|
|
274
273
|
/**
|
|
275
274
|
* Event that fires when player stops
|
|
276
275
|
*/
|
|
@@ -299,8 +298,4 @@ export interface VlcPlayerViewProps extends ViewProps {
|
|
|
299
298
|
* Event that fires when player loads
|
|
300
299
|
*/
|
|
301
300
|
onLoad?: (event: VideoInfo) => void;
|
|
302
|
-
/**
|
|
303
|
-
* Event that fires when player enters the background
|
|
304
|
-
*/
|
|
305
|
-
onBackground?: (event: Background) => void;
|
|
306
301
|
}
|
package/src/VlcPlayerView.tsx
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
VlcPlayerViewNativeProps,
|
|
6
6
|
VlcPlayerViewProps,
|
|
7
7
|
VLCPlayerViewRef,
|
|
8
|
+
type Paused,
|
|
8
9
|
type Warn,
|
|
9
10
|
type Error,
|
|
10
11
|
type PositionChanged,
|
|
11
12
|
type VideoInfo,
|
|
12
|
-
type Background,
|
|
13
13
|
} from "./VlcPlayer.types";
|
|
14
14
|
import { convertNativeProps } from "./utils/props";
|
|
15
15
|
|
|
@@ -30,6 +30,12 @@ const VlcPlayerView = forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
|
30
30
|
loggedRenderingChildrenWarning = true;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const onPaused = ({ nativeEvent }: { nativeEvent: Paused }) => {
|
|
34
|
+
if (props.onPaused) {
|
|
35
|
+
props.onPaused(nativeEvent);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
33
39
|
const onWarn = ({ nativeEvent }: { nativeEvent: Warn }) => {
|
|
34
40
|
if (props.onWarn) {
|
|
35
41
|
props.onWarn(nativeEvent);
|
|
@@ -58,21 +64,15 @@ const VlcPlayerView = forwardRef<VLCPlayerViewRef, VlcPlayerViewProps>(
|
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
|
|
61
|
-
const onBackground = ({ nativeEvent }: { nativeEvent: Background }) => {
|
|
62
|
-
if (props.onBackground) {
|
|
63
|
-
props.onBackground(nativeEvent);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
67
|
return (
|
|
68
68
|
<NativeView
|
|
69
69
|
{...nativeProps}
|
|
70
70
|
ref={ref}
|
|
71
|
+
onPaused={onPaused}
|
|
71
72
|
onWarn={onWarn}
|
|
72
73
|
onError={onError}
|
|
73
74
|
onPositionChanged={onPositionChanged}
|
|
74
75
|
onLoad={onLoad}
|
|
75
|
-
onBackground={onBackground}
|
|
76
76
|
/>
|
|
77
77
|
);
|
|
78
78
|
},
|