expo-libvlc-player 7.0.10 → 7.0.12

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
@@ -125,7 +125,7 @@ See the [Example App](example/App.tsx) for additional usage.
125
125
  | `play()` | Starts playback of the current player | `Promise<void>` |
126
126
  | `pause()` | Pauses playback of the current player | `Promise<void>` |
127
127
  | `stop()` | Stops playback of the current player | `Promise<void>` |
128
- | `seek(value: number, type?: "time" \| "position")` | Sets the time or position of the current player. Value must be an integer equal or greater than `0` and type defaults to `"time"` | `Promise<void>` |
128
+ | `seek(value: number, type?: "time" \| "position")` | Sets the time or position of the current player. Value must be a number equal or greater than `0` and type defaults to `"time"` | `Promise<void>` |
129
129
  | `record(path?: string)` | Starts or stops recording the current media. Path must be a valid directory or `undefined` to stop recording | `Promise<void>` |
130
130
  | `snapshot(path: string)` | Takes a snapshot of the current media. Path must be a valid directory | `Promise<void>` |
131
131
  | `postAction(action: 1 \| 2)` | Posts an answer to a [`Dialog`](#dialog). Action must be either `1` or `2` | `Promise<void>` |
@@ -144,12 +144,12 @@ The `LibVlcPlayerView` extends React Native `ViewProps` and implements the follo
144
144
  | `options` | Sets the options to initialize the media with. See the [VideoLAN Wiki](https://wiki.videolan.org/VLC_command-line_help/) for more | `[]` |
145
145
  | `tracks` | Sets the player audio, video and subtitle tracks. See [`Tracks`](#tracks) for more | `undefined` |
146
146
  | `slaves` | Sets the player audio and subtitle slaves. See [`Slave`](#slave) for more | `[]` |
147
- | `scale` | Sets the player scaling factor. Must be a float equal or greater than `0` | `0` |
148
- | `aspectRatio` | Sets the container aspect ratio. Must be a valid ratio, float, or `"auto"` | `undefined` |
147
+ | `scale` | Sets the player scaling factor. Must be a number equal or greater than `0` | `0` |
148
+ | `aspectRatio` | Sets the container aspect ratio. Must be a valid ratio, number, or `"auto"` | `undefined` |
149
149
  | `contentFit` | Sets how the video should be scaled to fit in the container | `"contain"` |
150
- | `rate` | Sets the player rate. Must be a float equal or greater than `1` | `1` |
151
- | `time` | Sets the initial player time. Must be an integer (ms) greater than `0` | `0` |
152
- | `volume` | Sets the player volume. Must be an integer between `0` and `100` | `100` |
150
+ | `rate` | Sets the player rate. Must be a number equal or greater than `1` | `1` |
151
+ | `time` | Sets the initial player time. Must be a number equal or greater than `0` | `0` |
152
+ | `volume` | Sets the player volume. Must be a number between `0` and `100` | `100` |
153
153
  | `mute` | Sets the player volume to `0` when `true` and previous value is restored when `false` | `false` |
154
154
  | `audioMixingMode` | Determines how the player will interact with other audio in the system | `"auto"` |
155
155
  | `repeat` | Determines whether the media should repeat once ended | `false` |
@@ -84,7 +84,7 @@ class LibVlcPlayerModule : Module() {
84
84
  view.slaves = slaves
85
85
  }
86
86
 
87
- Prop("scale", MediaPlayerConstants.DEFAULT_PLAYER_SCALE) { view: LibVlcPlayerView, scale: Float ->
87
+ Prop("scale", MediaPlayerConstants.DEFAULT_PLAYER_SCALE) { view: LibVlcPlayerView, scale: Double ->
88
88
  view.scale = scale
89
89
  }
90
90
 
@@ -92,7 +92,7 @@ class LibVlcPlayerModule : Module() {
92
92
  view.contentFit = contentFit
93
93
  }
94
94
 
95
- Prop("rate", MediaPlayerConstants.DEFAULT_PLAYER_RATE) { view: LibVlcPlayerView, rate: Float ->
95
+ Prop("rate", MediaPlayerConstants.DEFAULT_PLAYER_RATE) { view: LibVlcPlayerView, rate: Double ->
96
96
  view.rate = rate
97
97
  }
98
98
 
@@ -332,11 +332,11 @@ class LibVlcPlayerView(
332
332
  addPlayerSlaves(slaves)
333
333
 
334
334
  if (scale != MediaPlayerConstants.DEFAULT_PLAYER_SCALE) {
335
- player.setScale(scale)
335
+ player.setScale(scale.toFloat())
336
336
  }
337
337
 
338
338
  if (rate != MediaPlayerConstants.DEFAULT_PLAYER_RATE) {
339
- player.setRate(rate)
339
+ player.setRate(rate.toFloat())
340
340
  }
341
341
 
342
342
  if (time != MediaPlayerConstants.DEFAULT_PLAYER_TIME) {
@@ -398,12 +398,12 @@ class LibVlcPlayerView(
398
398
  return mediaTracks
399
399
  }
400
400
 
401
- fun getMediaLength(): Long {
402
- var length: Long = 0L
401
+ fun getMediaLength(): Int {
402
+ var length = 0
403
403
 
404
- val duration = mediaPlayer?.getLength() ?: 0L
404
+ val duration = mediaPlayer?.getLength()?.toInt() ?: 0
405
405
 
406
- if (duration > 0L) {
406
+ if (duration > 0) {
407
407
  length = duration
408
408
  }
409
409
 
@@ -411,21 +411,16 @@ class LibVlcPlayerView(
411
411
  }
412
412
 
413
413
  fun getMediaInfo(): MediaInfo {
414
- var mediaInfo = MediaInfo()
415
-
416
414
  val video = getVideoSize()
417
415
  val length = getMediaLength()
418
416
  val seekable = mediaPlayer?.isSeekable() ?: false
419
417
 
420
- mediaInfo =
421
- MediaInfo(
422
- width = video.width,
423
- height = video.height,
424
- length = length.toDouble(),
425
- seekable = seekable,
426
- )
427
-
428
- return mediaInfo
418
+ return MediaInfo(
419
+ width = video.width,
420
+ height = video.height,
421
+ length = length,
422
+ seekable = seekable,
423
+ )
429
424
  }
430
425
 
431
426
  fun getVideoSize(): Size {
@@ -445,7 +440,7 @@ class LibVlcPlayerView(
445
440
  val tracks = getMediaTracks()
446
441
  val length = getMediaLength()
447
442
  val hasVideo = tracks.video.any { track -> track.id != -1 }
448
- return hasVideo && hasVideoSize && length > 0L
443
+ return hasVideo && hasVideoSize && length > 0
449
444
  }
450
445
 
451
446
  val hasAudioOut: Boolean
@@ -485,10 +480,10 @@ class LibVlcPlayerView(
485
480
  }
486
481
  }
487
482
 
488
- var scale: Float = MediaPlayerConstants.DEFAULT_PLAYER_SCALE
483
+ var scale: Double = MediaPlayerConstants.DEFAULT_PLAYER_SCALE
489
484
  set(value) {
490
485
  field = value
491
- mediaPlayer?.setScale(value)
486
+ mediaPlayer?.setScale(value.toFloat())
492
487
  }
493
488
 
494
489
  var contentFit: VideoContentFit = VideoContentFit.CONTAIN
@@ -498,10 +493,10 @@ class LibVlcPlayerView(
498
493
  setContentFit(layout = pictureLayout)
499
494
  }
500
495
 
501
- var rate: Float = MediaPlayerConstants.DEFAULT_PLAYER_RATE
496
+ var rate: Double = MediaPlayerConstants.DEFAULT_PLAYER_RATE
502
497
  set(value) {
503
498
  field = value
504
- mediaPlayer?.setRate(value)
499
+ mediaPlayer?.setRate(value.toFloat())
505
500
  }
506
501
 
507
502
  var time: Int = MediaPlayerConstants.DEFAULT_PLAYER_TIME
@@ -510,19 +505,26 @@ class LibVlcPlayerView(
510
505
  set(value) {
511
506
  field = value
512
507
 
513
- val newVolume = value.coerceIn(MediaPlayerConstants.MIN_PLAYER_VOLUME, MediaPlayerConstants.MAX_PLAYER_VOLUME)
514
- MediaPlayerManager.audioFocusManager.oldVolume = newVolume
508
+ if (mute) return
515
509
 
516
- if (!mute) {
517
- mediaPlayer?.setVolume(newVolume)
518
- MediaPlayerManager.audioFocusManager.updateAudioFocus()
519
- }
510
+ val newVolume =
511
+ value.coerceIn(
512
+ MediaPlayerConstants.MIN_PLAYER_VOLUME,
513
+ MediaPlayerConstants.MAX_PLAYER_VOLUME,
514
+ )
515
+ mediaPlayer?.setVolume(newVolume)
516
+
517
+ MediaPlayerManager.audioFocusManager.updateAudioFocus()
520
518
  }
521
519
 
522
520
  var mute: Boolean = false
523
521
  set(value) {
524
522
  field = value
525
523
 
524
+ if (mute) {
525
+ MediaPlayerManager.audioFocusManager.oldVolume = volume
526
+ }
527
+
526
528
  val newVolume =
527
529
  if (value) {
528
530
  MediaPlayerConstants.MIN_PLAYER_VOLUME
@@ -1,8 +1,8 @@
1
1
  package expo.modules.libvlcplayer.constants
2
2
 
3
3
  object MediaPlayerConstants {
4
- const val DEFAULT_PLAYER_SCALE: Float = 0f
5
- const val DEFAULT_PLAYER_RATE: Float = 1f
4
+ const val DEFAULT_PLAYER_SCALE: Double = 0.0
5
+ const val DEFAULT_PLAYER_RATE: Double = 1.0
6
6
  const val DEFAULT_PLAYER_TIME: Int = 0
7
7
  const val MIN_PLAYER_VOLUME: Int = 0
8
8
  const val MAX_PLAYER_VOLUME: Int = 100
@@ -188,9 +188,8 @@ class AudioFocusManager(
188
188
 
189
189
  private fun duckPlayer(mediaPlayer: MediaPlayer?) {
190
190
  mediaPlayer?.let { player ->
191
- val duckVolume = player.getVolume() / 2
192
- player.setVolume(duckVolume)
193
- oldVolume = duckVolume
191
+ val volume = player.getVolume()
192
+ player.setVolume(volume / 2)
194
193
  }
195
194
  }
196
195
 
@@ -7,7 +7,7 @@ import java.io.Serializable
7
7
  class MediaInfo(
8
8
  @Field var width: Int = 0,
9
9
  @Field var height: Int = 0,
10
- @Field var length: Double = 0.0,
10
+ @Field var length: Int = 0,
11
11
  @Field var seekable: Boolean = false,
12
12
  ) : Record,
13
13
  Serializable
@@ -22,7 +22,7 @@ export interface LibVlcPlayerViewRef {
22
22
  /**
23
23
  * Sets the time or position of the current player
24
24
  *
25
- * @param value - Must be an integer equal or greater than `0`
25
+ * @param value - Must be a number equal or greater than `0`
26
26
  * @param type - Defaults to `"time"`
27
27
  *
28
28
  * @returns A promise which resolves to `void`
@@ -333,13 +333,13 @@ export interface LibVlcPlayerViewProps extends ViewProps {
333
333
  */
334
334
  slaves?: Slave[];
335
335
  /**
336
- * Sets the player scaling factor. Must be a float equal or greater than `0`
336
+ * Sets the player scaling factor. Must be a number equal or greater than `0`
337
337
  *
338
338
  * @default 0
339
339
  */
340
340
  scale?: number;
341
341
  /**
342
- * Sets the container aspect ratio. Must be a valid ratio, float, or `"auto"`
342
+ * Sets the container aspect ratio. Must be a valid ratio, number, or `"auto"`
343
343
  *
344
344
  * @example "16:9"
345
345
  *
@@ -355,19 +355,19 @@ export interface LibVlcPlayerViewProps extends ViewProps {
355
355
  */
356
356
  contentFit?: VideoContentFit;
357
357
  /**
358
- * Sets the player rate. Must be a float equal or greater than `1`
358
+ * Sets the player rate. Must be a number equal or greater than `1`
359
359
  *
360
360
  * @default 1
361
361
  */
362
362
  rate?: number;
363
363
  /**
364
- * Sets the initial player time. Must be an integer (ms) greater than `0`
364
+ * Sets the initial player time. Must be a number equal or greater than `0`
365
365
  *
366
366
  * @default 0
367
367
  */
368
368
  time?: number;
369
369
  /**
370
- * Sets the player volume. Must be an integer between `0` and `100`
370
+ * Sets the player volume. Must be a number between `0` and `100`
371
371
  *
372
372
  * @default 100
373
373
  */
@@ -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\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/consistent-type-definitions\nexport type LibVlcPlayerModuleEvents = {};\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 time or position of the current player\n *\n * @param value - Must be an integer equal or greater than `0`\n * @param type - Defaults to `\"time\"`\n *\n * @returns A promise which resolves to `void`\n */\n readonly seek: (value: number, type?: \"time\" | \"position\") => Promise<void>;\n /**\n * Starts or stops recording the current media\n *\n * @param path - Must be a valid directory or `undefined` to stop recording\n *\n * @returns A promise which resolves to `void`\n */\n readonly record: (path?: string) => Promise<void>;\n /**\n * Takes a snapshot of the current media\n *\n * @param path - Must be a valid directory\n *\n * @returns A promise which resolves to `void`\n */\n readonly snapshot: (path: string) => Promise<void>;\n /**\n * Posts an answer to a `Dialog`\n *\n * @param action - Must be either `1` or `2`\n *\n * @returns A promise which resolves to `void`\n */\n readonly postAction: (action: 1 | 2) => Promise<void>;\n /**\n * Posts a username and password to a login `Dialog`\n *\n * @param username - Must be a valid username, can't be empty\n * @param password - Must be a valid password, can be empty\n * @param store - If `true`, store the credentials\n *\n * @returns A promise which resolves to `void`\n */\n readonly postLogin: (username: string, password: string, store?: boolean) => Promise<void>;\n /**\n * Dismisses a `Dialog`\n *\n * @returns A promise which resolves to `void`\n */\n readonly dismiss: () => Promise<void>;\n /**\n * Enters Picture-in-Picture (PiP) mode\n *\n * @note Config plugin has to be configured for Picture-in-Picture (PiP) to work\n *\n * @returns A promise which resolves to `void`\n */\n readonly startPictureInPicture: () => Promise<void>;\n /**\n * Exits Picture-in-Picture (PiP) mode\n *\n * @platform ios\n *\n * @returns A promise which resolves to `void`\n */\n readonly stopPictureInPicture: () => Promise<void>;\n}\n\nexport type LibVlcSource = string | number | null;\n\nexport type LibVlcSlaveSource = string | number;\n\nexport interface Tracks {\n audio?: number;\n video?: number;\n subtitle?: number;\n}\n\nexport interface Slave {\n source: LibVlcSlaveSource;\n type: \"audio\" | \"subtitle\";\n selected?: boolean;\n}\n\nexport type VideoAspectRatio = \"auto\" | (string & {}) | number;\n\nexport type VideoContentFit = \"contain\" | \"cover\" | \"fill\";\n\nexport type AudioMixingMode = \"mixWithOthers\" | \"duckOthers\" | \"auto\" | \"doNotMix\";\n\nexport interface NativeEventProps {\n target: number;\n}\n\nexport interface NativeEvent<T> {\n nativeEvent: T & NativeEventProps;\n}\n\nexport type LibVlcEvent<T> = Omit<T & NativeEventProps, \"target\">;\n\nexport interface Error {\n message: string;\n}\n\nexport interface Time {\n value: number;\n}\n\nexport interface Position {\n value: number;\n}\n\nexport interface Snapshot {\n path: string;\n}\n\nexport interface Dialog {\n title: string;\n text: string;\n type: \"error\" | \"login\" | \"question\";\n cancelText?: string;\n action1Text?: string;\n action2Text?: string;\n}\n\nexport interface Recording {\n path: string | null;\n isRecording: 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}\n\n/**\n * @hidden\n */\ntype BufferingListener = () => void;\n\n/**\n * @hidden\n */\ntype PlayingListener = () => void;\n\n/**\n * @hidden\n */\ntype PausedListener = () => void;\n\n/**\n * @hidden\n */\ntype StoppedListener = () => void;\n\n/**\n * @hidden\n */\ntype EncounteredErrorListener = (event: NativeEvent<Error>) => void;\n\n/**\n * @hidden\n */\ntype TimeChangedListener = (event: NativeEvent<Time>) => void;\n\n/**\n * @hidden\n */\ntype PositionChangedListener = (event: NativeEvent<Position>) => void;\n\n/**\n * @hidden\n */\ntype ESAddedListener = (event: NativeEvent<MediaTracks>) => void;\n\n/**\n * @hidden\n */\ntype RecordChangedListener = (event: NativeEvent<Recording>) => void;\n\n/**\n * @hidden\n */\ntype SnapshotTakenListener = (event: NativeEvent<Snapshot>) => void;\n\n/**\n * @hidden\n */\ntype DialogDisplayListener = (event: NativeEvent<Dialog>) => void;\n\n/**\n * @hidden\n */\ntype FirstPlayListener = (event: NativeEvent<MediaInfo>) => void;\n\n/**\n * @hidden\n */\ntype ForegroundListener = () => void;\n\n/**\n * @hidden\n */\ntype BackgroundListener = () => void;\n\n/**\n * @hidden\n */\ntype PictureInPictureStartListener = () => void;\n\n/**\n * @hidden\n */\ntype PictureInPictureStopListener = () => void;\n\n/**\n * @hidden\n */\nexport interface LibVlcPlayerViewNativeProps extends ViewProps {\n ref?: React.Ref<LibVlcPlayerViewRef>;\n source?: LibVlcSource;\n options?: string[];\n tracks?: Tracks;\n slaves?: Slave[];\n scale?: number;\n aspectRatio?: VideoAspectRatio;\n contentFit?: VideoContentFit;\n rate?: number;\n time?: number;\n volume?: number;\n mute?: boolean;\n audioMixingMode?: AudioMixingMode;\n repeat?: boolean;\n autoplay?: boolean;\n pictureInPicture?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEncounteredError?: EncounteredErrorListener;\n onDialogDisplay?: DialogDisplayListener;\n onTimeChanged?: TimeChangedListener;\n onPositionChanged?: PositionChangedListener;\n onESAdded?: ESAddedListener;\n onRecordChanged?: RecordChangedListener;\n onSnapshotTaken?: SnapshotTakenListener;\n onFirstPlay?: FirstPlayListener;\n onForeground?: ForegroundListener;\n onBackground?: BackgroundListener;\n onPictureInPictureStart?: PictureInPictureStartListener;\n onPictureInPictureStop?: PictureInPictureStopListener;\n}\n\nexport interface LibVlcPlayerViewProps extends ViewProps {\n /**\n * Allows getting a ref to the component instance.\n *\n * Once the component unmounts, React will set `ref.current` to `null`\n *\n * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}\n */\n ref: React.RefObject<LibVlcPlayerViewRef | null>;\n /**\n * Sets the source of the media to be played. Set to `null` to release the player\n *\n * @example\n *\n * ```tsx\n * const BIG_BUCK_BUNNY =\n * \"https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_h264.mov\";\n *\n * <LibVlcPlayerView source={BIG_BUCK_BUNNY} />\n * ```\n */\n source: LibVlcSource;\n /**\n * Sets the options to initialize the media with\n *\n * @see {@link https://wiki.videolan.org/VLC_command-line_help/ VideoLAN Wiki}\n *\n * @example\n *\n * ```tsx\n * const options = [\"--network-caching=1000\"];\n *\n * <LibVlcPlayerView\n * source={BIG_BUCK_BUNNY}\n * options={options}\n * />\n * ```\n *\n * @default []\n */\n options?: string[];\n /**\n * Sets the player audio, video and subtitle tracks\n *\n * @example\n *\n * ```tsx\n * const tracks = {\n * audio: -1,\n * video: 1,\n * subtitle: 1,\n * };\n *\n * <LibVlcPlayerView\n * source={BIG_BUCK_BUNNY}\n * tracks={tracks}\n * />\n * ```\n *\n * @default undefined\n */\n tracks?: Tracks;\n /**\n * Sets the player audio and subtitle slaves\n *\n * @example\n *\n * ```tsx\n * const slaves = [\n * {\n * source: \"file://path/to/subtitle.srt\",\n * type: \"subtitle\",\n * selected: true,\n * },\n * ];\n *\n * <LibVlcPlayerView\n * source={BIG_BUCK_BUNNY}\n * slaves={slaves}\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 container aspect ratio. Must be a valid ratio, float, or `\"auto\"`\n *\n * @example \"16:9\"\n *\n * @default undefined\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * Sets how the video should be scaled to fit in the container\n *\n * @example \"cover\"\n *\n * @default \"contain\"\n */\n contentFit?: VideoContentFit;\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 (ms) greater than `0`\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` and previous value is restored 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 * @example \"doNotMix\"\n *\n * @default \"auto\"\n */\n audioMixingMode?: AudioMixingMode;\n /**\n * Determines whether the media should repeat once ended\n *\n * @default false\n */\n repeat?: boolean;\n /**\n * Determines whether the media should autoplay once created\n *\n * @default true\n */\n autoplay?: boolean;\n /**\n * Determines whether the player should allow Picture-in-Picture (PiP) mode\n *\n * @default false\n */\n pictureInPicture?: 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 `EncounteredError` player event\n */\n onEncounteredError?: (event: Error) => void;\n /**\n * Called after a `Dialog` needs to be displayed\n */\n onDialogDisplay?: (event: Dialog) => void;\n /**\n * Called after the `TimeChanged` player event\n */\n onTimeChanged?: (event: Time) => 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 `RecordChanged` player event\n */\n onRecordChanged?: (event: Recording) => void;\n /**\n * Called after a media snapshot is taken\n */\n onSnapshotTaken?: (event: Snapshot) => void;\n /**\n * Called after the player first playing event\n */\n onFirstPlay?: (event: MediaInfo) => void;\n /**\n * Called after the player enters the foreground\n */\n onForeground?: () => void;\n /**\n * Called after the player enters the background\n */\n onBackground?: () => void;\n /**\n * Called after the player enters Picture-in-Picture (PiP) mode\n */\n onPictureInPictureStart?: () => void;\n /**\n * Called after the player exits Picture-in-Picture (PiP) mode\n */\n onPictureInPictureStop?: () => 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\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/consistent-type-definitions\nexport type LibVlcPlayerModuleEvents = {};\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 time or position of the current player\n *\n * @param value - Must be a number equal or greater than `0`\n * @param type - Defaults to `\"time\"`\n *\n * @returns A promise which resolves to `void`\n */\n readonly seek: (value: number, type?: \"time\" | \"position\") => Promise<void>;\n /**\n * Starts or stops recording the current media\n *\n * @param path - Must be a valid directory or `undefined` to stop recording\n *\n * @returns A promise which resolves to `void`\n */\n readonly record: (path?: string) => Promise<void>;\n /**\n * Takes a snapshot of the current media\n *\n * @param path - Must be a valid directory\n *\n * @returns A promise which resolves to `void`\n */\n readonly snapshot: (path: string) => Promise<void>;\n /**\n * Posts an answer to a `Dialog`\n *\n * @param action - Must be either `1` or `2`\n *\n * @returns A promise which resolves to `void`\n */\n readonly postAction: (action: 1 | 2) => Promise<void>;\n /**\n * Posts a username and password to a login `Dialog`\n *\n * @param username - Must be a valid username, can't be empty\n * @param password - Must be a valid password, can be empty\n * @param store - If `true`, store the credentials\n *\n * @returns A promise which resolves to `void`\n */\n readonly postLogin: (username: string, password: string, store?: boolean) => Promise<void>;\n /**\n * Dismisses a `Dialog`\n *\n * @returns A promise which resolves to `void`\n */\n readonly dismiss: () => Promise<void>;\n /**\n * Enters Picture-in-Picture (PiP) mode\n *\n * @note Config plugin has to be configured for Picture-in-Picture (PiP) to work\n *\n * @returns A promise which resolves to `void`\n */\n readonly startPictureInPicture: () => Promise<void>;\n /**\n * Exits Picture-in-Picture (PiP) mode\n *\n * @platform ios\n *\n * @returns A promise which resolves to `void`\n */\n readonly stopPictureInPicture: () => Promise<void>;\n}\n\nexport type LibVlcSource = string | number | null;\n\nexport type LibVlcSlaveSource = string | number;\n\nexport interface Tracks {\n audio?: number;\n video?: number;\n subtitle?: number;\n}\n\nexport interface Slave {\n source: LibVlcSlaveSource;\n type: \"audio\" | \"subtitle\";\n selected?: boolean;\n}\n\nexport type VideoAspectRatio = \"auto\" | (string & {}) | number;\n\nexport type VideoContentFit = \"contain\" | \"cover\" | \"fill\";\n\nexport type AudioMixingMode = \"mixWithOthers\" | \"duckOthers\" | \"auto\" | \"doNotMix\";\n\nexport interface NativeEventProps {\n target: number;\n}\n\nexport interface NativeEvent<T> {\n nativeEvent: T & NativeEventProps;\n}\n\nexport type LibVlcEvent<T> = Omit<T & NativeEventProps, \"target\">;\n\nexport interface Error {\n message: string;\n}\n\nexport interface Time {\n value: number;\n}\n\nexport interface Position {\n value: number;\n}\n\nexport interface Snapshot {\n path: string;\n}\n\nexport interface Dialog {\n title: string;\n text: string;\n type: \"error\" | \"login\" | \"question\";\n cancelText?: string;\n action1Text?: string;\n action2Text?: string;\n}\n\nexport interface Recording {\n path: string | null;\n isRecording: 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}\n\n/**\n * @hidden\n */\ntype BufferingListener = () => void;\n\n/**\n * @hidden\n */\ntype PlayingListener = () => void;\n\n/**\n * @hidden\n */\ntype PausedListener = () => void;\n\n/**\n * @hidden\n */\ntype StoppedListener = () => void;\n\n/**\n * @hidden\n */\ntype EncounteredErrorListener = (event: NativeEvent<Error>) => void;\n\n/**\n * @hidden\n */\ntype TimeChangedListener = (event: NativeEvent<Time>) => void;\n\n/**\n * @hidden\n */\ntype PositionChangedListener = (event: NativeEvent<Position>) => void;\n\n/**\n * @hidden\n */\ntype ESAddedListener = (event: NativeEvent<MediaTracks>) => void;\n\n/**\n * @hidden\n */\ntype RecordChangedListener = (event: NativeEvent<Recording>) => void;\n\n/**\n * @hidden\n */\ntype SnapshotTakenListener = (event: NativeEvent<Snapshot>) => void;\n\n/**\n * @hidden\n */\ntype DialogDisplayListener = (event: NativeEvent<Dialog>) => void;\n\n/**\n * @hidden\n */\ntype FirstPlayListener = (event: NativeEvent<MediaInfo>) => void;\n\n/**\n * @hidden\n */\ntype ForegroundListener = () => void;\n\n/**\n * @hidden\n */\ntype BackgroundListener = () => void;\n\n/**\n * @hidden\n */\ntype PictureInPictureStartListener = () => void;\n\n/**\n * @hidden\n */\ntype PictureInPictureStopListener = () => void;\n\n/**\n * @hidden\n */\nexport interface LibVlcPlayerViewNativeProps extends ViewProps {\n ref?: React.Ref<LibVlcPlayerViewRef>;\n source?: LibVlcSource;\n options?: string[];\n tracks?: Tracks;\n slaves?: Slave[];\n scale?: number;\n aspectRatio?: VideoAspectRatio;\n contentFit?: VideoContentFit;\n rate?: number;\n time?: number;\n volume?: number;\n mute?: boolean;\n audioMixingMode?: AudioMixingMode;\n repeat?: boolean;\n autoplay?: boolean;\n pictureInPicture?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEncounteredError?: EncounteredErrorListener;\n onDialogDisplay?: DialogDisplayListener;\n onTimeChanged?: TimeChangedListener;\n onPositionChanged?: PositionChangedListener;\n onESAdded?: ESAddedListener;\n onRecordChanged?: RecordChangedListener;\n onSnapshotTaken?: SnapshotTakenListener;\n onFirstPlay?: FirstPlayListener;\n onForeground?: ForegroundListener;\n onBackground?: BackgroundListener;\n onPictureInPictureStart?: PictureInPictureStartListener;\n onPictureInPictureStop?: PictureInPictureStopListener;\n}\n\nexport interface LibVlcPlayerViewProps extends ViewProps {\n /**\n * Allows getting a ref to the component instance.\n *\n * Once the component unmounts, React will set `ref.current` to `null`\n *\n * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}\n */\n ref: React.RefObject<LibVlcPlayerViewRef | null>;\n /**\n * Sets the source of the media to be played. Set to `null` to release the player\n *\n * @example\n *\n * ```tsx\n * const BIG_BUCK_BUNNY =\n * \"https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_h264.mov\";\n *\n * <LibVlcPlayerView source={BIG_BUCK_BUNNY} />\n * ```\n */\n source: LibVlcSource;\n /**\n * Sets the options to initialize the media with\n *\n * @see {@link https://wiki.videolan.org/VLC_command-line_help/ VideoLAN Wiki}\n *\n * @example\n *\n * ```tsx\n * const options = [\"--network-caching=1000\"];\n *\n * <LibVlcPlayerView\n * source={BIG_BUCK_BUNNY}\n * options={options}\n * />\n * ```\n *\n * @default []\n */\n options?: string[];\n /**\n * Sets the player audio, video and subtitle tracks\n *\n * @example\n *\n * ```tsx\n * const tracks = {\n * audio: -1,\n * video: 1,\n * subtitle: 1,\n * };\n *\n * <LibVlcPlayerView\n * source={BIG_BUCK_BUNNY}\n * tracks={tracks}\n * />\n * ```\n *\n * @default undefined\n */\n tracks?: Tracks;\n /**\n * Sets the player audio and subtitle slaves\n *\n * @example\n *\n * ```tsx\n * const slaves = [\n * {\n * source: \"file://path/to/subtitle.srt\",\n * type: \"subtitle\",\n * selected: true,\n * },\n * ];\n *\n * <LibVlcPlayerView\n * source={BIG_BUCK_BUNNY}\n * slaves={slaves}\n * />\n * ```\n *\n * @default []\n */\n slaves?: Slave[];\n /**\n * Sets the player scaling factor. Must be a number equal or greater than `0`\n *\n * @default 0\n */\n scale?: number;\n /**\n * Sets the container aspect ratio. Must be a valid ratio, number, or `\"auto\"`\n *\n * @example \"16:9\"\n *\n * @default undefined\n */\n aspectRatio?: VideoAspectRatio;\n /**\n * Sets how the video should be scaled to fit in the container\n *\n * @example \"cover\"\n *\n * @default \"contain\"\n */\n contentFit?: VideoContentFit;\n /**\n * Sets the player rate. Must be a number equal or greater than `1`\n *\n * @default 1\n */\n rate?: number;\n /**\n * Sets the initial player time. Must be a number equal or greater than `0`\n *\n * @default 0\n */\n time?: number;\n /**\n * Sets the player volume. Must be a number between `0` and `100`\n *\n * @default 100\n */\n volume?: number;\n /**\n * Sets the player volume to `0` when `true` and previous value is restored 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 * @example \"doNotMix\"\n *\n * @default \"auto\"\n */\n audioMixingMode?: AudioMixingMode;\n /**\n * Determines whether the media should repeat once ended\n *\n * @default false\n */\n repeat?: boolean;\n /**\n * Determines whether the media should autoplay once created\n *\n * @default true\n */\n autoplay?: boolean;\n /**\n * Determines whether the player should allow Picture-in-Picture (PiP) mode\n *\n * @default false\n */\n pictureInPicture?: 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 `EncounteredError` player event\n */\n onEncounteredError?: (event: Error) => void;\n /**\n * Called after a `Dialog` needs to be displayed\n */\n onDialogDisplay?: (event: Dialog) => void;\n /**\n * Called after the `TimeChanged` player event\n */\n onTimeChanged?: (event: Time) => 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 `RecordChanged` player event\n */\n onRecordChanged?: (event: Recording) => void;\n /**\n * Called after a media snapshot is taken\n */\n onSnapshotTaken?: (event: Snapshot) => void;\n /**\n * Called after the player first playing event\n */\n onFirstPlay?: (event: MediaInfo) => void;\n /**\n * Called after the player enters the foreground\n */\n onForeground?: () => void;\n /**\n * Called after the player enters the background\n */\n onBackground?: () => void;\n /**\n * Called after the player enters Picture-in-Picture (PiP) mode\n */\n onPictureInPictureStart?: () => void;\n /**\n * Called after the player exits Picture-in-Picture (PiP) mode\n */\n onPictureInPictureStop?: () => void;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  enum MediaPlayerConstants {
2
- static let defaultPlayerScale: Float = 0.0
3
- static let defaultPlayerRate: Float = 1.0
2
+ static let defaultPlayerScale: Double = 0.0
3
+ static let defaultPlayerRate: Double = 1.0
4
4
  static let defaultPlayerTime: Int = 0
5
5
  static let minPlayerVolume: Int = 0
6
6
  static let maxPlayerVolume: Int = 100
@@ -65,7 +65,7 @@ public class LibVlcPlayerModule: Module {
65
65
  view.slaves = slaves
66
66
  }
67
67
 
68
- Prop("scale", MediaPlayerConstants.defaultPlayerScale) { (view: LibVlcPlayerView, scale: Float) in
68
+ Prop("scale", MediaPlayerConstants.defaultPlayerScale) { (view: LibVlcPlayerView, scale: Double) in
69
69
  view.scale = scale
70
70
  }
71
71
 
@@ -73,7 +73,7 @@ public class LibVlcPlayerModule: Module {
73
73
  view.contentFit = contentFit
74
74
  }
75
75
 
76
- Prop("rate", MediaPlayerConstants.defaultPlayerRate) { (view: LibVlcPlayerView, rate: Float) in
76
+ Prop("rate", MediaPlayerConstants.defaultPlayerRate) { (view: LibVlcPlayerView, rate: Double) in
77
77
  view.rate = rate
78
78
  }
79
79
 
@@ -211,11 +211,11 @@ class LibVlcPlayerView: ExpoView {
211
211
  addPlayerSlaves(slaves)
212
212
 
213
213
  if scale != MediaPlayerConstants.defaultPlayerScale {
214
- player.scaleFactor = scale
214
+ player.scaleFactor = Float(scale)
215
215
  }
216
216
 
217
217
  if rate != MediaPlayerConstants.defaultPlayerRate {
218
- player.rate = rate
218
+ player.rate = Float(rate)
219
219
  }
220
220
 
221
221
  if time != MediaPlayerConstants.defaultPlayerTime {
@@ -274,10 +274,10 @@ class LibVlcPlayerView: ExpoView {
274
274
  return mediaTracks
275
275
  }
276
276
 
277
- func getMediaLength() -> Int32 {
278
- var length: Int32 = 0
277
+ func getMediaLength() -> Int {
278
+ var length = 0
279
279
 
280
- let duration = mediaPlayer?.media?.length.intValue ?? 0
280
+ let duration = Int(mediaPlayer?.media?.length.intValue ?? 0)
281
281
 
282
282
  if duration > 0 {
283
283
  length = duration
@@ -287,20 +287,16 @@ class LibVlcPlayerView: ExpoView {
287
287
  }
288
288
 
289
289
  func getMediaInfo() -> MediaInfo {
290
- var mediaInfo = MediaInfo()
291
-
292
290
  let video = getVideoSize()
293
291
  let length = getMediaLength()
294
292
  let seekable = mediaPlayer?.isSeekable ?? false
295
293
 
296
- mediaInfo = MediaInfo(
294
+ return MediaInfo(
297
295
  width: Int(video.width),
298
296
  height: Int(video.height),
299
- length: Double(length),
297
+ length: length,
300
298
  seekable: seekable
301
299
  )
302
-
303
- return mediaInfo
304
300
  }
305
301
 
306
302
  func getVideoSize() -> CGSize {
@@ -360,9 +356,9 @@ class LibVlcPlayerView: ExpoView {
360
356
  }
361
357
  }
362
358
 
363
- var scale: Float = MediaPlayerConstants.defaultPlayerScale {
359
+ var scale: Double = MediaPlayerConstants.defaultPlayerScale {
364
360
  didSet {
365
- mediaPlayer?.scaleFactor = scale
361
+ mediaPlayer?.scaleFactor = Float(scale)
366
362
  }
367
363
  }
368
364
 
@@ -373,9 +369,9 @@ class LibVlcPlayerView: ExpoView {
373
369
  }
374
370
  }
375
371
 
376
- var rate: Float = MediaPlayerConstants.defaultPlayerRate {
372
+ var rate: Double = MediaPlayerConstants.defaultPlayerRate {
377
373
  didSet {
378
- mediaPlayer?.rate = rate
374
+ mediaPlayer?.rate = Float(rate)
379
375
  }
380
376
  }
381
377
 
@@ -383,18 +379,24 @@ class LibVlcPlayerView: ExpoView {
383
379
 
384
380
  var volume: Int = MediaPlayerConstants.maxPlayerVolume {
385
381
  didSet {
386
- let newVolume = max(MediaPlayerConstants.minPlayerVolume, min(MediaPlayerConstants.maxPlayerVolume, volume))
387
- oldVolume = newVolume
382
+ if mute { return }
388
383
 
389
- if !mute {
390
- mediaPlayer?.audio?.volume = Int32(newVolume)
391
- MediaPlayerManager.shared.audioSessionManager.setAppropriateAudioSession()
392
- }
384
+ let newVolume = max(
385
+ MediaPlayerConstants.minPlayerVolume,
386
+ min(MediaPlayerConstants.maxPlayerVolume, volume)
387
+ )
388
+ mediaPlayer?.audio?.volume = Int32(newVolume)
389
+
390
+ MediaPlayerManager.shared.audioSessionManager.setAppropriateAudioSession()
393
391
  }
394
392
  }
395
393
 
396
394
  var mute: Bool = false {
397
395
  didSet {
396
+ if mute {
397
+ oldVolume = volume
398
+ }
399
+
398
400
  let newVolume = mute ?
399
401
  MediaPlayerConstants.minPlayerVolume :
400
402
  oldVolume
@@ -8,7 +8,7 @@ struct MediaInfo: Record {
8
8
  var height: Int = 0
9
9
 
10
10
  @Field
11
- var length: Double = 0.0
11
+ var length: Int = 0
12
12
 
13
13
  @Field
14
14
  var seekable: Bool = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "7.0.10",
3
+ "version": "7.0.12",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -25,7 +25,7 @@ export interface LibVlcPlayerViewRef {
25
25
  /**
26
26
  * Sets the time or position of the current player
27
27
  *
28
- * @param value - Must be an integer equal or greater than `0`
28
+ * @param value - Must be a number equal or greater than `0`
29
29
  * @param type - Defaults to `"time"`
30
30
  *
31
31
  * @returns A promise which resolves to `void`
@@ -373,13 +373,13 @@ export interface LibVlcPlayerViewProps extends ViewProps {
373
373
  */
374
374
  slaves?: Slave[];
375
375
  /**
376
- * Sets the player scaling factor. Must be a float equal or greater than `0`
376
+ * Sets the player scaling factor. Must be a number equal or greater than `0`
377
377
  *
378
378
  * @default 0
379
379
  */
380
380
  scale?: number;
381
381
  /**
382
- * Sets the container aspect ratio. Must be a valid ratio, float, or `"auto"`
382
+ * Sets the container aspect ratio. Must be a valid ratio, number, or `"auto"`
383
383
  *
384
384
  * @example "16:9"
385
385
  *
@@ -395,19 +395,19 @@ export interface LibVlcPlayerViewProps extends ViewProps {
395
395
  */
396
396
  contentFit?: VideoContentFit;
397
397
  /**
398
- * Sets the player rate. Must be a float equal or greater than `1`
398
+ * Sets the player rate. Must be a number equal or greater than `1`
399
399
  *
400
400
  * @default 1
401
401
  */
402
402
  rate?: number;
403
403
  /**
404
- * Sets the initial player time. Must be an integer (ms) greater than `0`
404
+ * Sets the initial player time. Must be a number equal or greater than `0`
405
405
  *
406
406
  * @default 0
407
407
  */
408
408
  time?: number;
409
409
  /**
410
- * Sets the player volume. Must be an integer between `0` and `100`
410
+ * Sets the player volume. Must be a number between `0` and `100`
411
411
  *
412
412
  * @default 100
413
413
  */