expo-libvlc-player 2.0.12 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -135,7 +135,7 @@ The `LibVlcPlayerView` extends React Native `ViewProps` and implements the follo
135
135
  | `volume` | Sets the player volume. Must be an integer between `0` and `100` | `100` |
136
136
  | `mute` | Sets the player volume to `0` when `true`. Previous value is set when `false` | `false` |
137
137
  | `audioMixingMode` | Determines how the player will interact with other audio in the system | `"auto"` |
138
- | `playInBackground` | Determines whether the player should continue playing in the background | `false` |
138
+ | `playInBackground` | Determines whether the media should continue playing in the background | `false` |
139
139
  | `autoplay` | Determines whether the media should autoplay once created | `true` |
140
140
  | `repeat` | Determines whether the media should repeat once ended | `false` |
141
141
 
@@ -1,7 +1,7 @@
1
1
  apply plugin: "com.android.library"
2
2
 
3
3
  group = "expo.modules.libvlcplayer"
4
- version = "2.0.12"
4
+ version = "2.0.14"
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -27,7 +27,7 @@ android {
27
27
  namespace "expo.modules.libvlcplayer"
28
28
  defaultConfig {
29
29
  versionCode 1
30
- versionName "2.0.12"
30
+ versionName "2.0.14"
31
31
  consumerProguardFiles("proguard-rules.pro")
32
32
  }
33
33
  lintOptions {
@@ -103,9 +103,7 @@ class LibVlcPlayerView(
103
103
 
104
104
  addPlayerSlaves()
105
105
 
106
- if (autoplay) {
107
- mediaPlayer!!.play()
108
- }
106
+ mediaPlayer!!.play()
109
107
 
110
108
  shouldCreate = false
111
109
  firstPlay = true
@@ -302,7 +300,7 @@ class LibVlcPlayerView(
302
300
 
303
301
  var slaves: ArrayList<Slave> = ArrayList()
304
302
  set(value) {
305
- val newSlaves = value.filter { it !in field }
303
+ val newSlaves = value.filter { slave -> slave !in field }
306
304
 
307
305
  field = field.apply { addAll(newSlaves) }
308
306
 
@@ -383,6 +381,15 @@ class LibVlcPlayerView(
383
381
  }
384
382
 
385
383
  var autoplay: Boolean = true
384
+ set(value) {
385
+ field = value
386
+
387
+ options.removeStartPausedOption()
388
+
389
+ if (!value) {
390
+ options.add("--start-paused")
391
+ }
392
+ }
386
393
 
387
394
  var repeat: Boolean = false
388
395
  set(value) {
@@ -395,7 +402,13 @@ class LibVlcPlayerView(
395
402
  }
396
403
 
397
404
  fun play() {
398
- mediaPlayer?.play()
405
+ mediaPlayer?.let { player ->
406
+ if (options.hasStartPausedOption()) {
407
+ player.play()
408
+ }
409
+
410
+ player.play()
411
+ }
399
412
  }
400
413
 
401
414
  fun pause() {
@@ -424,7 +437,7 @@ class LibVlcPlayerView(
424
437
  ":no-audio",
425
438
  )
426
439
 
427
- return this.any { it in options }
440
+ return this.any { option -> option in options }
428
441
  }
429
442
 
430
443
  internal fun ArrayList<String>.hasRepeatOption(): Boolean {
@@ -435,10 +448,32 @@ class LibVlcPlayerView(
435
448
  ":input-repeat=",
436
449
  )
437
450
 
438
- return this.any { arg ->
439
- options.any { option ->
440
- arg.startsWith(option)
451
+ return this.any { option ->
452
+ options.any { value ->
453
+ option.startsWith(value)
441
454
  }
442
455
  }
443
456
  }
457
+
458
+ internal fun ArrayList<String>.hasStartPausedOption(): Boolean {
459
+ val options =
460
+ setOf(
461
+ "--start-paused",
462
+ "-start-paused",
463
+ ":start-paused",
464
+ )
465
+
466
+ return this.any { option -> option in options }
467
+ }
468
+
469
+ internal fun ArrayList<String>.removeStartPausedOption() {
470
+ val options =
471
+ setOf(
472
+ "--start-paused",
473
+ "-start-paused",
474
+ ":start-paused",
475
+ )
476
+
477
+ this.removeAll(options)
478
+ }
444
479
  }
@@ -235,7 +235,7 @@ export interface LibVlcPlayerViewProps extends ViewProps {
235
235
  */
236
236
  audioMixingMode?: AudioMixingMode;
237
237
  /**
238
- * Determines whether the player should continue playing after entering the background
238
+ * Determines whether the media should continue playing after entering the background
239
239
  *
240
240
  * @default false
241
241
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LibVlcPlayer.types.js","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nexport interface LibVlcPlayerViewRef {\n /**\n * Starts playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly stop: () => Promise<void>;\n /**\n * Sets the position of the current player\n *\n * @param position - Must be a float between `0` and `1`\n *\n * @returns A promise which resolves to `void`\n */\n readonly seek: (position: number) => Promise<void>;\n}\n\nexport type LibVlcSource = string | number | null;\n\nexport interface Tracks {\n audio?: number;\n video?: number;\n subtitle?: number;\n}\n\nexport interface Slave {\n source: NonNullable<LibVlcSource>;\n type: \"audio\" | \"subtitle\";\n selected?: boolean;\n}\n\nexport interface Track {\n id: number;\n name: string;\n}\n\nexport interface MediaTracks {\n audio: Track[];\n video: Track[];\n subtitle: Track[];\n}\n\nexport interface MediaInfo {\n width: number;\n height: number;\n length: number;\n seekable: boolean;\n tracks: MediaTracks;\n}\n\nexport type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"doNotMix\";\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 = () => void;\n\n/**\n * @hidden\n */\nexport type StoppedListener = () => void;\n\n/**\n * @hidden\n */\nexport type EndReachedListener = () => void;\n\n/**\n * @hidden\n */\nexport type EncounteredErrorListener = (event: { nativeEvent: Error }) => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\nexport type PositionChangedListener = (event: {\n nativeEvent: Position;\n}) => void;\n\nexport type Position = { position: number };\n\n/**\n * @hidden\n */\nexport type ESAddedListener = (event: { nativeEvent: MediaTracks }) => void;\n\n/**\n * @hidden\n */\nexport type FirstPlayListener = (event: { nativeEvent: MediaInfo }) => void;\n\n/**\n * @hidden\n */\nexport type BackgroundListener = () => void;\n\n/**\n * @hidden\n */\nexport interface LibVlcPlayerViewNativeProps {\n ref?: React.Ref<LibVlcPlayerViewRef>;\n source?: LibVlcSource;\n options?: string[];\n tracks?: Tracks;\n slaves?: Slave[];\n scale?: number;\n aspectRatio?: string | null;\n rate?: number;\n time?: number;\n volume?: number;\n mute?: boolean;\n audioMixingMode?: AudioMixingMode;\n playInBackground?: boolean;\n autoplay?: boolean;\n repeat?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEndReached?: EndReachedListener;\n onEncounteredError?: EncounteredErrorListener;\n onPositionChanged?: PositionChangedListener;\n onESAdded?: ESAddedListener;\n onFirstPlay?: FirstPlayListener;\n onBackground?: BackgroundListener;\n}\n\nexport interface LibVlcPlayerViewProps extends ViewProps {\n /**\n * Sets the source of the media to be played. Set to `null` to release the player\n */\n source: LibVlcSource;\n /**\n * Sets the VLC options to initialize the player with\n *\n * https://wiki.videolan.org/VLC_command-line_help/\n *\n * @example [\"--network-caching=1000\"]\n *\n * @default []\n */\n options?: string[];\n /**\n * Sets the player audio, video and subtitle tracks\n *\n * @example\n * ```tsx\n * <LibVlcPlayerView\n * tracks={{\n * audio: 0,\n * video: 1,\n * subtitle: 2,\n * }}\n * />\n * ```\n *\n * @default undefined\n */\n tracks?: Tracks;\n /**\n * Sets the player audio and subtitle slaves\n *\n * @example\n * ```tsx\n * <LibVlcPlayerView\n * slaves={[\n * {\n * source: \"file://path/to/subtitle.srt\",\n * type: \"subtitle\",\n * selected: true\n * },\n * ]}\n * />\n * ```\n *\n * @default []\n */\n slaves?: Slave[];\n /**\n * Sets the player scaling factor. Must be a float equal or greater than `0`\n *\n * @default 0\n */\n scale?: number;\n /**\n * Sets the player aspect ratio. Must be a valid string or `null` for default\n *\n * @example \"16:9\"\n *\n * @default undefined\n */\n aspectRatio?: string | null;\n /**\n * Sets the player rate. Must be a float equal or greater than `1`\n *\n * @default 1\n */\n rate?: number;\n /**\n * Sets the initial player time. Must be an integer in milliseconds\n *\n * @default 0\n */\n time?: number;\n /**\n * Sets the player volume. Must be an integer between `0` and `100`\n *\n * @default 100\n */\n volume?: number;\n /**\n * Sets the player volume to `0` when `true`. Previous value is set when `false`\n *\n * @default false\n */\n mute?: boolean;\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 entering the background\n *\n * @default false\n */\n playInBackground?: boolean;\n /**\n * Determines whether the media should autoplay once created\n *\n * @default true\n */\n autoplay?: boolean;\n /**\n * Determines whether the media should repeat once ended\n *\n * @default false\n */\n repeat?: boolean;\n /**\n * Called after the `Buffering` player event\n */\n onBuffering?: () => void;\n /**\n * Called after the `Playing` player event\n */\n onPlaying?: () => void;\n /**\n * Called after the `Paused` player event\n */\n onPaused?: () => void;\n /**\n * Called after the `Stopped` player event\n */\n onStopped?: () => void;\n /**\n * Called after the `EndReached` player event\n */\n onEndReached?: () => void;\n /**\n * Called after the `EncounteredError` player event\n */\n onEncounteredError?: (event: Error) => void;\n /**\n * Called after the `PositionChanged` player event\n */\n onPositionChanged?: (event: Position) => void;\n /**\n * Called after the `ESAdded` player event\n */\n onESAdded?: (event: MediaTracks) => void;\n /**\n * Called after the first `Playing` player event\n */\n onFirstPlay?: (event: MediaInfo) => void;\n /**\n * Called after the player enters the background\n */\n onBackground?: () => void;\n}\n"]}
1
+ {"version":3,"file":"LibVlcPlayer.types.js","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps } from \"react-native\";\n\nexport interface LibVlcPlayerViewRef {\n /**\n * Starts playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly play: () => Promise<void>;\n /**\n * Pauses playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly pause: () => Promise<void>;\n /**\n * Stops playback of the current player\n *\n * @returns A promise which resolves to `void`\n */\n readonly stop: () => Promise<void>;\n /**\n * Sets the position of the current player\n *\n * @param position - Must be a float between `0` and `1`\n *\n * @returns A promise which resolves to `void`\n */\n readonly seek: (position: number) => Promise<void>;\n}\n\nexport type LibVlcSource = string | number | null;\n\nexport interface Tracks {\n audio?: number;\n video?: number;\n subtitle?: number;\n}\n\nexport interface Slave {\n source: NonNullable<LibVlcSource>;\n type: \"audio\" | \"subtitle\";\n selected?: boolean;\n}\n\nexport interface Track {\n id: number;\n name: string;\n}\n\nexport interface MediaTracks {\n audio: Track[];\n video: Track[];\n subtitle: Track[];\n}\n\nexport interface MediaInfo {\n width: number;\n height: number;\n length: number;\n seekable: boolean;\n tracks: MediaTracks;\n}\n\nexport type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"doNotMix\";\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 = () => void;\n\n/**\n * @hidden\n */\nexport type StoppedListener = () => void;\n\n/**\n * @hidden\n */\nexport type EndReachedListener = () => void;\n\n/**\n * @hidden\n */\nexport type EncounteredErrorListener = (event: { nativeEvent: Error }) => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\nexport type PositionChangedListener = (event: {\n nativeEvent: Position;\n}) => void;\n\nexport type Position = { position: number };\n\n/**\n * @hidden\n */\nexport type ESAddedListener = (event: { nativeEvent: MediaTracks }) => void;\n\n/**\n * @hidden\n */\nexport type FirstPlayListener = (event: { nativeEvent: MediaInfo }) => void;\n\n/**\n * @hidden\n */\nexport type BackgroundListener = () => void;\n\n/**\n * @hidden\n */\nexport interface LibVlcPlayerViewNativeProps {\n ref?: React.Ref<LibVlcPlayerViewRef>;\n source?: LibVlcSource;\n options?: string[];\n tracks?: Tracks;\n slaves?: Slave[];\n scale?: number;\n aspectRatio?: string | null;\n rate?: number;\n time?: number;\n volume?: number;\n mute?: boolean;\n audioMixingMode?: AudioMixingMode;\n playInBackground?: boolean;\n autoplay?: boolean;\n repeat?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEndReached?: EndReachedListener;\n onEncounteredError?: EncounteredErrorListener;\n onPositionChanged?: PositionChangedListener;\n onESAdded?: ESAddedListener;\n onFirstPlay?: FirstPlayListener;\n onBackground?: BackgroundListener;\n}\n\nexport interface LibVlcPlayerViewProps extends ViewProps {\n /**\n * Sets the source of the media to be played. Set to `null` to release the player\n */\n source: LibVlcSource;\n /**\n * Sets the VLC options to initialize the player with\n *\n * https://wiki.videolan.org/VLC_command-line_help/\n *\n * @example [\"--network-caching=1000\"]\n *\n * @default []\n */\n options?: string[];\n /**\n * Sets the player audio, video and subtitle tracks\n *\n * @example\n * ```tsx\n * <LibVlcPlayerView\n * tracks={{\n * audio: 0,\n * video: 1,\n * subtitle: 2,\n * }}\n * />\n * ```\n *\n * @default undefined\n */\n tracks?: Tracks;\n /**\n * Sets the player audio and subtitle slaves\n *\n * @example\n * ```tsx\n * <LibVlcPlayerView\n * slaves={[\n * {\n * source: \"file://path/to/subtitle.srt\",\n * type: \"subtitle\",\n * selected: true\n * },\n * ]}\n * />\n * ```\n *\n * @default []\n */\n slaves?: Slave[];\n /**\n * Sets the player scaling factor. Must be a float equal or greater than `0`\n *\n * @default 0\n */\n scale?: number;\n /**\n * Sets the player aspect ratio. Must be a valid string or `null` for default\n *\n * @example \"16:9\"\n *\n * @default undefined\n */\n aspectRatio?: string | null;\n /**\n * Sets the player rate. Must be a float equal or greater than `1`\n *\n * @default 1\n */\n rate?: number;\n /**\n * Sets the initial player time. Must be an integer in milliseconds\n *\n * @default 0\n */\n time?: number;\n /**\n * Sets the player volume. Must be an integer between `0` and `100`\n *\n * @default 100\n */\n volume?: number;\n /**\n * Sets the player volume to `0` when `true`. Previous value is set when `false`\n *\n * @default false\n */\n mute?: boolean;\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 media should continue playing after entering the background\n *\n * @default false\n */\n playInBackground?: boolean;\n /**\n * Determines whether the media should autoplay once created\n *\n * @default true\n */\n autoplay?: boolean;\n /**\n * Determines whether the media should repeat once ended\n *\n * @default false\n */\n repeat?: boolean;\n /**\n * Called after the `Buffering` player event\n */\n onBuffering?: () => void;\n /**\n * Called after the `Playing` player event\n */\n onPlaying?: () => void;\n /**\n * Called after the `Paused` player event\n */\n onPaused?: () => void;\n /**\n * Called after the `Stopped` player event\n */\n onStopped?: () => void;\n /**\n * Called after the `EndReached` player event\n */\n onEndReached?: () => void;\n /**\n * Called after the `EncounteredError` player event\n */\n onEncounteredError?: (event: Error) => void;\n /**\n * Called after the `PositionChanged` player event\n */\n onPositionChanged?: (event: Position) => void;\n /**\n * Called after the `ESAdded` player event\n */\n onESAdded?: (event: MediaTracks) => void;\n /**\n * Called after the first `Playing` player event\n */\n onFirstPlay?: (event: MediaInfo) => void;\n /**\n * Called after the player enters the background\n */\n onBackground?: () => void;\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "platforms": [
3
- "apple",
3
+ "ios",
4
4
  "android"
5
5
  ],
6
- "apple": {
6
+ "ios": {
7
7
  "modules": [
8
8
  "LibVlcPlayerModule"
9
9
  ]
@@ -73,9 +73,7 @@ class LibVlcPlayerView: ExpoView {
73
73
 
74
74
  addPlayerSlaves()
75
75
 
76
- if autoplay {
77
- mediaPlayer!.play()
78
- }
76
+ mediaPlayer!.play()
79
77
 
80
78
  shouldCreate = false
81
79
  firstPlay = true
@@ -249,7 +247,7 @@ class LibVlcPlayerView: ExpoView {
249
247
  var slaves: [Slave] {
250
248
  get { _slaves }
251
249
  set {
252
- let newSlaves = newValue.filter { !_slaves.contains($0) }
250
+ let newSlaves = newValue.filter { slave in !_slaves.contains(slave) }
253
251
 
254
252
  _slaves += newSlaves
255
253
 
@@ -331,7 +329,15 @@ class LibVlcPlayerView: ExpoView {
331
329
  }
332
330
  }
333
331
 
334
- var autoplay: Bool = true
332
+ var autoplay: Bool = true {
333
+ didSet {
334
+ options.removeStartPausedOption()
335
+
336
+ if !autoplay {
337
+ options.append("--start-paused")
338
+ }
339
+ }
340
+ }
335
341
 
336
342
  var shouldRepeat: Bool = false {
337
343
  didSet {
@@ -343,7 +349,13 @@ class LibVlcPlayerView: ExpoView {
343
349
  }
344
350
 
345
351
  func play() {
346
- mediaPlayer?.play()
352
+ if let player = mediaPlayer {
353
+ if options.hasStartPausedOption() {
354
+ player.play()
355
+ }
356
+
357
+ player.play()
358
+ }
347
359
  }
348
360
 
349
361
  func pause() {
@@ -367,24 +379,52 @@ class LibVlcPlayerView: ExpoView {
367
379
 
368
380
  private extension Array where Element == String {
369
381
  func hasAudioOption() -> Bool {
370
- let options: Set<String> = [
371
- "--no-audio", "-no-audio", ":no-audio",
382
+ let options = [
383
+ "--no-audio",
384
+ "-no-audio",
385
+ ":no-audio",
372
386
  ]
373
387
 
374
- return contains { arg in options.contains(arg) }
388
+ return contains { option in options.contains(option) }
375
389
  }
376
390
  }
377
391
 
378
392
  extension Array where Element == String {
379
393
  func hasRepeatOption() -> Bool {
380
- let options: Set<String> = [
381
- "--input-repeat=", "-input-repeat=", ":input-repeat=",
394
+ let options = [
395
+ "--input-repeat=",
396
+ "-input-repeat=",
397
+ ":input-repeat=",
382
398
  ]
383
399
 
384
- return contains { arg in
385
- options.contains { option in
386
- arg.hasPrefix(option)
400
+ return contains { option in
401
+ options.contains { value in
402
+ option.hasPrefix(value)
387
403
  }
388
404
  }
389
405
  }
390
406
  }
407
+
408
+ extension Array where Element == String {
409
+ func hasStartPausedOption() -> Bool {
410
+ let options = [
411
+ "--start-paused",
412
+ "-start-paused",
413
+ ":start-paused",
414
+ ]
415
+
416
+ return contains { option in options.contains(option) }
417
+ }
418
+ }
419
+
420
+ extension Array where Element == String {
421
+ mutating func removeStartPausedOption() {
422
+ let options = [
423
+ "--start-paused",
424
+ "-start-paused",
425
+ ":start-paused",
426
+ ]
427
+
428
+ removeAll { option in options.contains(option) }
429
+ }
430
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -251,7 +251,7 @@ export interface LibVlcPlayerViewProps extends ViewProps {
251
251
  */
252
252
  audioMixingMode?: AudioMixingMode;
253
253
  /**
254
- * Determines whether the player should continue playing after entering the background
254
+ * Determines whether the media should continue playing after entering the background
255
255
  *
256
256
  * @default false
257
257
  */