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,328 @@
1
+ package expo.modules.libvlcplayer
2
+
3
+ import expo.modules.libvlcplayer.enums.AudioMixingMode
4
+
5
+ import android.content.Context
6
+ import android.net.Uri
7
+
8
+ import com.facebook.react.bridge.Arguments
9
+ import com.facebook.react.bridge.ReadableMap
10
+ import com.facebook.react.bridge.WritableMap
11
+
12
+ import expo.modules.kotlin.AppContext
13
+ import expo.modules.kotlin.views.ExpoView
14
+ import expo.modules.kotlin.viewevent.EventDispatcher
15
+
16
+ import org.videolan.libvlc.LibVLC
17
+ import org.videolan.libvlc.MediaPlayer
18
+ import org.videolan.libvlc.MediaPlayer.Event
19
+ import org.videolan.libvlc.MediaPlayer.EventListener
20
+ import org.videolan.libvlc.Media
21
+
22
+ import org.videolan.libvlc.util.VLCVideoLayout
23
+ import org.videolan.libvlc.interfaces.IMedia
24
+
25
+ import java.util.UUID
26
+
27
+ const val DEFAULT_PLAYER_RATE: Float = 1f
28
+ const val MIN_PLAYER_VOLUME: Int = 0
29
+ const val MAX_PLAYER_VOLUME: Int = 100
30
+ const val PLAYER_VOLUME_STEP: Int = 10
31
+
32
+ val ENABLE_SUBTITLES = true
33
+ val USE_TEXTURE_VIEW = false
34
+
35
+ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
36
+ internal val playerViewId: String = UUID.randomUUID().toString()
37
+
38
+ internal val videoLayout: VLCVideoLayout = VLCVideoLayout(context).also { layout ->
39
+ layout.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
40
+ addView(layout)
41
+ }
42
+
43
+ private var libVLC: LibVLC? = null
44
+ internal var mediaPlayer: MediaPlayer? = null
45
+
46
+ private var previousVolume: Int = MAX_PLAYER_VOLUME
47
+ private var repeat: Boolean = false
48
+ private var autoplay: Boolean = true
49
+
50
+ private val onBuffering by EventDispatcher()
51
+ private val onPlaying by EventDispatcher()
52
+ private val onPaused by EventDispatcher()
53
+ private val onStopped by EventDispatcher()
54
+ private val onEnded by EventDispatcher()
55
+ private val onRepeat by EventDispatcher()
56
+ private val onWarn by EventDispatcher()
57
+ private val onError by EventDispatcher()
58
+ private val onPositionChanged by EventDispatcher()
59
+ private val onLoad by EventDispatcher<WritableMap>()
60
+ internal val onBackground by EventDispatcher()
61
+
62
+ private lateinit var audioFocusManager: AudioFocusManager
63
+
64
+ init {
65
+ VlcPlayerManager.registerView(this)
66
+ audioFocusManager = VlcPlayerManager.audioFocusManager
67
+ }
68
+
69
+ fun createPlayer() {
70
+ destroyPlayer()
71
+
72
+ libVLC = LibVLC(context, options)
73
+ mediaPlayer = MediaPlayer(libVLC)
74
+
75
+ mediaPlayer?.let { player ->
76
+ player.setEventListener(EventListener { event ->
77
+ when (event.type) {
78
+ Event.Buffering -> {
79
+ onBuffering(mapOf())
80
+
81
+ val audioTracks = Arguments.createArray()
82
+
83
+ if (player.getAudioTracksCount() > 0) {
84
+ val audios = player.getAudioTracks()
85
+
86
+ audios.forEach { track ->
87
+ if (track.id == -1) return@forEach
88
+ val trackMap = Arguments.createMap()
89
+ trackMap.putInt("id", track.id)
90
+ trackMap.putString("name", track.name)
91
+ audioTracks.pushMap(trackMap)
92
+ }
93
+ }
94
+
95
+ val subtitleTracks = Arguments.createArray()
96
+
97
+ if (player.getSpuTracksCount() > 0) {
98
+ val subtitles = player.getSpuTracks()
99
+
100
+ subtitles.forEach { track ->
101
+ val trackMap = Arguments.createMap()
102
+ trackMap.putInt("id", track.id)
103
+ trackMap.putString("name", track.name)
104
+ subtitleTracks.pushMap(trackMap)
105
+ }
106
+ }
107
+
108
+ val video = player.getCurrentVideoTrack()
109
+ val ratio = player.getAspectRatio()
110
+ val length = player.getLength()
111
+ val tracks = Arguments.createMap().apply {
112
+ putArray("audio", audioTracks)
113
+ putArray("subtitle", subtitleTracks)
114
+ }
115
+ val seekable = player.isSeekable()
116
+
117
+ val videoInfo = Arguments.createMap().apply {
118
+ putInt("width", video?.width ?: 0)
119
+ putInt("height", video?.height ?: 0)
120
+ putString("aspectRatio", ratio)
121
+ putDouble("duration", length.toDouble())
122
+ putMap("tracks", tracks)
123
+ putBoolean("seekable", seekable)
124
+ }
125
+
126
+ onLoad(videoInfo)
127
+ }
128
+
129
+ Event.Playing -> {
130
+ onPlaying(mapOf())
131
+ audioFocusManager.updateAudioFocus()
132
+ }
133
+
134
+ Event.Paused -> {
135
+ onPaused(mapOf())
136
+ audioFocusManager.updateAudioFocus()
137
+ }
138
+
139
+ Event.Stopped -> {
140
+ onStopped(mapOf())
141
+ audioFocusManager.updateAudioFocus()
142
+
143
+ val position = 0f
144
+ onPositionChanged(mapOf("position" to position))
145
+ }
146
+
147
+ Event.EndReached -> {
148
+ onEnded(mapOf())
149
+
150
+ val manualRepeat = !options.hasRepeatOptions() && repeat
151
+
152
+ if (manualRepeat) {
153
+ player.stop()
154
+ player.play()
155
+ onRepeat(mapOf())
156
+ }
157
+ }
158
+
159
+ Event.EncounteredError -> {
160
+ val error = mapOf("error" to "Player encountered an error")
161
+ onError(error)
162
+ }
163
+
164
+ Event.PositionChanged -> {
165
+ val position = mapOf("position" to event.positionChanged)
166
+ onPositionChanged(position)
167
+ }
168
+ }
169
+ })
170
+
171
+ player.attachViews(videoLayout, null, ENABLE_SUBTITLES, USE_TEXTURE_VIEW)
172
+
173
+ try {
174
+ val media = Media(libVLC, Uri.parse(uri))
175
+ player.setMedia(media)
176
+ } catch (_: Exception) {
177
+ val error = mapOf("error" to "Invalid URI, media could not be set")
178
+ onError(error)
179
+ }
180
+
181
+ if (autoplay) {
182
+ player.play()
183
+ }
184
+ }
185
+ }
186
+
187
+ fun destroyPlayer() {
188
+ mediaPlayer?.let { player ->
189
+ player.stop()
190
+ player.detachViews()
191
+ player.release()
192
+ }
193
+ libVLC?.release()
194
+ }
195
+
196
+ var uri: String = ""
197
+ set(value) {
198
+ val old = field
199
+ field = value
200
+
201
+ if (value != old) {
202
+ createPlayer()
203
+ }
204
+ }
205
+
206
+ fun setSubtitle(subtitle: ReadableMap?) {
207
+ val uri = subtitle?.getString("uri") ?: ""
208
+ val enable = if (subtitle?.hasKey("enable") == true) {
209
+ subtitle.getBoolean("enable")
210
+ } else {
211
+ ENABLE_SUBTITLES
212
+ }
213
+
214
+ try {
215
+ mediaPlayer?.addSlave(IMedia.Slave.Type.Subtitle, Uri.parse(uri), enable)
216
+ } catch (_: Exception) {
217
+ val error = mapOf("error" to "Invalid URI, subtitle could not be set")
218
+ onError(error)
219
+ }
220
+ }
221
+
222
+ var options: ArrayList<String> = ArrayList<String>()
223
+ set(value) {
224
+ val old = field
225
+ field = value
226
+
227
+ if (value != old) {
228
+ createPlayer()
229
+ }
230
+ }
231
+
232
+ fun setVolume(volume: Int) {
233
+ val newVolume = volume.coerceIn(MIN_PLAYER_VOLUME, MAX_PLAYER_VOLUME)
234
+ previousVolume = newVolume
235
+
236
+ mediaPlayer?.setVolume(newVolume)
237
+ audioFocusManager.updateAudioFocus()
238
+ }
239
+
240
+ fun setMute(mute: Boolean) {
241
+ val newVolume = if (!mute) {
242
+ previousVolume.coerceIn(PLAYER_VOLUME_STEP, MAX_PLAYER_VOLUME)
243
+ } else {
244
+ MIN_PLAYER_VOLUME
245
+ }
246
+
247
+ mediaPlayer?.setVolume(newVolume)
248
+ audioFocusManager.updateAudioFocus()
249
+ }
250
+
251
+ fun setRate(rate: Float) {
252
+ mediaPlayer?.setRate(rate)
253
+ }
254
+
255
+ fun setTracks(tracks: ReadableMap?) {
256
+ val audioTrack = tracks?.getInt("audio") ?: -1
257
+ val subtitleTrack = tracks?.getInt("subtitle") ?: -1
258
+
259
+ mediaPlayer?.let { player ->
260
+ player.setAudioTrack(audioTrack)
261
+ player.setSpuTrack(subtitleTrack)
262
+ }
263
+ }
264
+
265
+ fun setRepeat(repeat: Boolean) {
266
+ if (repeat && options.hasRepeatOptions()) {
267
+ val warn = mapOf("warn" to "Repeat already enabled in options")
268
+ return onWarn(warn)
269
+ }
270
+
271
+ this.repeat = repeat
272
+ }
273
+
274
+ fun setAspectRatio(aspectRatio: String?) {
275
+ mediaPlayer?.setAspectRatio(aspectRatio)
276
+ }
277
+
278
+ var audioMixingMode: AudioMixingMode = AudioMixingMode.AUTO
279
+ set(value) {
280
+ field = value
281
+ audioFocusManager.updateAudioFocus()
282
+ }
283
+
284
+ var playInBackground: Boolean = false
285
+ set(value) {
286
+ field = value
287
+ audioFocusManager.updateAudioFocus()
288
+ }
289
+
290
+ fun setAutoplay(autoplay: Boolean) {
291
+ this.autoplay = autoplay
292
+ }
293
+
294
+ fun play() {
295
+ mediaPlayer?.play()
296
+ }
297
+
298
+ fun pause() {
299
+ mediaPlayer?.pause()
300
+ }
301
+
302
+ fun stop() {
303
+ mediaPlayer?.stop()
304
+ }
305
+
306
+ fun seek(position: Float) {
307
+ mediaPlayer?.let { player ->
308
+ if (player.isSeekable()) {
309
+ player.setPosition(position)
310
+ } else {
311
+ val error = mapOf("error" to "Media is not seekable")
312
+ onError(error)
313
+ }
314
+ }
315
+ }
316
+
317
+ private fun ArrayList<String>.hasRepeatOptions(): Boolean {
318
+ val prefixes = setOf(
319
+ "--input-repeat=", "-input-repeat=", ":input-repeat="
320
+ )
321
+
322
+ return this.any { arg ->
323
+ prefixes.any { prefix ->
324
+ arg.startsWith(prefix)
325
+ }
326
+ }
327
+ }
328
+ }
@@ -0,0 +1,20 @@
1
+ package expo.modules.libvlcplayer.enums
2
+
3
+ import expo.modules.kotlin.types.Enumerable
4
+
5
+ enum class AudioMixingMode(val value: String) : Enumerable {
6
+ MIX_WITH_OTHERS("mixWithOthers"),
7
+ DUCK_OTHERS("duckOthers"),
8
+ AUTO("auto"),
9
+ DO_NOT_MIX("doNotMix");
10
+
11
+ val priority: Int
12
+ get() {
13
+ return when (this) {
14
+ DO_NOT_MIX -> 3
15
+ AUTO -> 2
16
+ DUCK_OTHERS -> 1
17
+ MIX_WITH_OTHERS -> 0
18
+ }
19
+ }
20
+ }
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./plugin/build/withExpoLibVlcPlayer");
@@ -0,0 +1,278 @@
1
+ import * as React from "react";
2
+ import type { ViewProps } from "react-native";
3
+ export interface VLCPlayerViewRef {
4
+ /**
5
+ * Starts playback for the current player
6
+ *
7
+ * @returns void
8
+ */
9
+ readonly play: () => Promise<void>;
10
+ /**
11
+ * Pauses playback for the current player
12
+ *
13
+ * @returns void
14
+ */
15
+ readonly pause: () => Promise<void>;
16
+ /**
17
+ * Stops playback for the current player
18
+ *
19
+ * @returns void
20
+ */
21
+ readonly stop: () => Promise<void>;
22
+ /**
23
+ * Sets position of the current player
24
+ *
25
+ * @param position - Must be a float number between `0` and `1`
26
+ *
27
+ * @returns void
28
+ */
29
+ readonly seek: (position: number) => Promise<void>;
30
+ }
31
+ /**
32
+ * @hidden
33
+ */
34
+ export type BufferingListener = () => void;
35
+ /**
36
+ * @hidden
37
+ */
38
+ export type PlayingPausedListener = () => void;
39
+ /**
40
+ * @hidden
41
+ */
42
+ export type StoppedListener = () => void;
43
+ /**
44
+ * @hidden
45
+ */
46
+ export type EndedListener = () => void;
47
+ /**
48
+ * @hidden
49
+ */
50
+ export type RepeatListener = () => void;
51
+ /**
52
+ * @hidden
53
+ */
54
+ export type WarnListener = (event: {
55
+ nativeEvent: Warn;
56
+ }) => void;
57
+ export type Warn = {
58
+ warn: string;
59
+ };
60
+ /**
61
+ * @hidden
62
+ */
63
+ export type ErrorListener = (event: {
64
+ nativeEvent: Error;
65
+ }) => void;
66
+ export type Error = {
67
+ error: string;
68
+ };
69
+ /**
70
+ * @hidden
71
+ */
72
+ export type PositionChangedListener = (event: {
73
+ nativeEvent: PositionChanged;
74
+ }) => void;
75
+ export type PositionChanged = {
76
+ position: number;
77
+ };
78
+ /**
79
+ * @hidden
80
+ */
81
+ export type LoadListener = (event: {
82
+ nativeEvent: VideoInfo;
83
+ }) => void;
84
+ /**
85
+ * @hidden
86
+ */
87
+ export type BackgroundListener = () => void;
88
+ export interface Track {
89
+ id: number;
90
+ name: string;
91
+ }
92
+ export interface VideoTracks {
93
+ audio: Track[];
94
+ subtitle: Track[];
95
+ }
96
+ export interface VideoInfo {
97
+ width: number;
98
+ height: number;
99
+ aspectRatio: string | null;
100
+ duration: number;
101
+ tracks: VideoTracks;
102
+ seekable: boolean;
103
+ }
104
+ export interface Subtitle {
105
+ uri: string;
106
+ enable: boolean;
107
+ }
108
+ export interface TracksOptions {
109
+ audio: number;
110
+ subtitle: number;
111
+ }
112
+ /**
113
+ * @hidden
114
+ */
115
+ export interface VlcPlayerViewNativeProps {
116
+ ref?: React.Ref<VLCPlayerViewRef>;
117
+ uri?: string;
118
+ subtitle?: Subtitle;
119
+ options?: string[];
120
+ volume?: number;
121
+ mute?: boolean;
122
+ rate?: number;
123
+ tracks?: TracksOptions;
124
+ repeat?: boolean;
125
+ aspectRatio?: string;
126
+ audioMixingMode?: AudioMixingMode;
127
+ playInBackground?: boolean;
128
+ autoplay?: boolean;
129
+ onBuffering?: BufferingListener;
130
+ onPlaying?: PlayingPausedListener;
131
+ onPaused?: PlayingPausedListener;
132
+ onStopped?: StoppedListener;
133
+ onEnded?: EndedListener;
134
+ onRepeat?: RepeatListener;
135
+ onWarn?: WarnListener;
136
+ onError?: ErrorListener;
137
+ onPositionChanged?: PositionChangedListener;
138
+ onLoad?: LoadListener;
139
+ onBackground?: BackgroundListener;
140
+ }
141
+ export type AudioMixingMode = "mixWithOthers" | "duckOthers" | "auto" | "doNotMix";
142
+ export interface VlcPlayerViewProps extends ViewProps {
143
+ /**
144
+ * Sets the URI of the media to be played
145
+ */
146
+ uri: string;
147
+ /**
148
+ * Sets subtitle URI and enabled state
149
+ *
150
+ * @example
151
+ * ```tsx
152
+ * <VLCPlayerView
153
+ * subtitle={{
154
+ * uri: "file://",
155
+ * enable: false,
156
+ * }}
157
+ * />
158
+ * ```
159
+ */
160
+ subtitle?: Subtitle;
161
+ /**
162
+ * https://wiki.videolan.org/VLC_command-line_help/
163
+ *
164
+ * Sets the VLC options to initialize the player with
165
+ *
166
+ * @example ["--network-caching=1000"]
167
+ *
168
+ * @default []
169
+ *
170
+ */
171
+ options?: string[];
172
+ /**
173
+ * Controls the player volume, must be an integer number between `0` and `100`
174
+ *
175
+ * @default 100
176
+ *
177
+ */
178
+ volume?: number;
179
+ /**
180
+ * Sets the player volume to `0`
181
+ */
182
+ mute?: boolean;
183
+ /**
184
+ * Controls the player rate, must be a float number
185
+ *
186
+ * @default 1
187
+ *
188
+ */
189
+ rate?: number;
190
+ /**
191
+ * Sets the player audio and subtitle tracks, see `VideoInfo` for tracks type
192
+ *
193
+ * @example
194
+ * ```tsx
195
+ * <VLCPlayerView
196
+ * tracks={{
197
+ * audio: 1,
198
+ * subtitle: 2,
199
+ * }}
200
+ * />
201
+ * ```
202
+ */
203
+ tracks?: TracksOptions;
204
+ /**
205
+ * Repeats media once playback is ended
206
+ */
207
+ repeat?: boolean;
208
+ /**
209
+ * Sets the player aspect ratio, must be a valid string
210
+ *
211
+ * @example "16:9"
212
+ */
213
+ aspectRatio?: string;
214
+ /**
215
+ * Determines how the player will interact with other audio playing in the system
216
+ *
217
+ * @default 'auto'
218
+ */
219
+ audioMixingMode?: AudioMixingMode;
220
+ /**
221
+ * Determines whether the player should continue playing after the app enters the background
222
+ *
223
+ * @default false
224
+ */
225
+ playInBackground?: boolean;
226
+ /**
227
+ * Autoplays media once player is created
228
+ *
229
+ * @default true
230
+ *
231
+ */
232
+ autoplay?: boolean;
233
+ /**
234
+ * Event that fires when player buffers
235
+ */
236
+ onBuffering?: () => void;
237
+ /**
238
+ * Event that fires when player plays
239
+ */
240
+ onPlaying?: () => void;
241
+ /**
242
+ * Event that fires when player pauses
243
+ */
244
+ onPaused?: () => void;
245
+ /**
246
+ * Event that fires when player stops
247
+ */
248
+ onStopped?: () => void;
249
+ /**
250
+ * Event that fires when player reaches an end
251
+ */
252
+ onEnded?: () => void;
253
+ /**
254
+ * Event that fires when player repeats
255
+ */
256
+ onRepeat?: () => void;
257
+ /**
258
+ * Event that fires when player emits a warning
259
+ */
260
+ onWarn?: (event: Warn) => void;
261
+ /**
262
+ * Event that fires when player encounters an error
263
+ */
264
+ onError?: (event: Error) => void;
265
+ /**
266
+ * Event that fires when player position changes
267
+ */
268
+ onPositionChanged?: (event: PositionChanged) => void;
269
+ /**
270
+ * Event that fires when player loads
271
+ */
272
+ onLoad?: (event: VideoInfo) => void;
273
+ /**
274
+ * Event that fires when player enters the background
275
+ */
276
+ onBackground?: () => void;
277
+ }
278
+ //# 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,KAAK,MAAM,OAAO,CAAC;AAC/B,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,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,KAAK,IAAI,CAAC;AAElE,MAAM,MAAM,IAAI,GAAG;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 +1 @@
1
+ {"version":3,"file":"VlcPlayer.types.js","sourceRoot":"","sources":["../src/VlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface VLCPlayerViewRef {\n /**\n * Starts playback for the current player\n *\n * @returns void\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback for the current player\n *\n * @returns void\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback for the current player\n *\n * @returns 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 PlayingPausedListener = () => void;\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\n/**\n * @hidden\n */\nexport type BackgroundListener = () => 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 repeat?: boolean;\n aspectRatio?: string;\n audioMixingMode?: AudioMixingMode;\n playInBackground?: boolean;\n autoplay?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingPausedListener;\n onPaused?: PlayingPausedListener;\n onStopped?: StoppedListener;\n onEnded?: EndedListener;\n onRepeat?: RepeatListener;\n onWarn?: WarnListener;\n onError?: ErrorListener;\n onPositionChanged?: PositionChangedListener;\n onLoad?: LoadListener;\n onBackground?: BackgroundListener;\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 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 * Repeats media once playback is ended\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?: () => 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 * Event that fires when player enters the background\n */\n onBackground?: () => void;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { NativeModule } from "expo";
2
+ declare class VlcPlayerModule extends NativeModule<{}> {
3
+ }
4
+ declare const _default: VlcPlayerModule;
5
+ export default _default;
6
+ //# sourceMappingURL=VlcPlayerModule.d.ts.map
@@ -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,4 @@
1
+ import { requireNativeModule } from "expo";
2
+ // This call loads the native module object from the JSI.
3
+ export default requireNativeModule("ExpoLibVlcPlayer");
4
+ //# sourceMappingURL=VlcPlayerModule.js.map
@@ -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,5 @@
1
+ import * as React from "react";
2
+ import { VlcPlayerViewProps, VLCPlayerViewRef } from "./VlcPlayer.types";
3
+ declare const VlcPlayerView: React.ForwardRefExoticComponent<VlcPlayerViewProps & React.RefAttributes<VLCPlayerViewRef>>;
4
+ export default VlcPlayerView;
5
+ //# sourceMappingURL=VlcPlayerView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VlcPlayerView.d.ts","sourceRoot":"","sources":["../src/VlcPlayerView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAQ3B,QAAA,MAAM,aAAa,6FAmDlB,CAAC;AAEF,eAAe,aAAa,CAAC"}