expo-libvlc-player 3.1.2 → 3.2.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.
package/README.md CHANGED
@@ -117,7 +117,7 @@ return (
117
117
  <View style={{ aspectRatio: 16 / 9 }}>
118
118
  <LibVlcPlayerView
119
119
  style={{ height: "100%" }}
120
- source="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
120
+ source="https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_h264.mov"
121
121
  />
122
122
  </View>
123
123
  );
@@ -164,6 +164,7 @@ The `LibVlcPlayerView` extends React Native `ViewProps` and implements the follo
164
164
  | `slaves` | Sets the player audio and subtitle slaves array. See [`Slave`](#slave) for more | `[]` |
165
165
  | `scale` | Sets the player scaling factor. Must be a float equal or greater than `0` | `0` |
166
166
  | `aspectRatio` | Sets the player aspect ratio. Must be a valid string or `null` for default | `undefined` |
167
+ | `contentFit` | Sets how the video should be scaled to fit in the container | `"contain"` |
167
168
  | `rate` | Sets the player rate. Must be a float equal or greater than `1` | `1` |
168
169
  | `time` | Sets the initial player time. Must be an integer in milliseconds | `0` |
169
170
  | `volume` | Sets the player volume. Must be an integer between `0` and `100` | `100` |
@@ -1,7 +1,7 @@
1
1
  apply plugin: "com.android.library"
2
2
 
3
3
  group = "expo.modules.libvlcplayer"
4
- version = "3.1.2"
4
+ version = "3.2.0"
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 "3.1.2"
30
+ versionName "3.2.0"
31
31
  consumerProguardFiles("proguard-rules.pro")
32
32
  }
33
33
  lintOptions {
@@ -3,6 +3,7 @@ package expo.modules.libvlcplayer
3
3
  import expo.modules.kotlin.modules.Module
4
4
  import expo.modules.kotlin.modules.ModuleDefinition
5
5
  import expo.modules.libvlcplayer.enums.AudioMixingMode
6
+ import expo.modules.libvlcplayer.enums.VideoContentFit
6
7
  import expo.modules.libvlcplayer.records.Slave
7
8
  import expo.modules.libvlcplayer.records.Tracks
8
9
 
@@ -89,6 +90,10 @@ class LibVlcPlayerModule : Module() {
89
90
  view.aspectRatio = aspectRatio
90
91
  }
91
92
 
93
+ Prop("contentFit") { view: LibVlcPlayerView, contentFit: VideoContentFit? ->
94
+ view.contentFit = contentFit ?: VideoContentFit.CONTAIN
95
+ }
96
+
92
97
  Prop("rate") { view: LibVlcPlayerView, rate: Float? ->
93
98
  view.rate = rate ?: DEFAULT_PLAYER_RATE
94
99
  }
@@ -2,6 +2,7 @@ package expo.modules.libvlcplayer
2
2
 
3
3
  import android.content.Context
4
4
  import android.graphics.Bitmap
5
+ import android.graphics.Matrix
5
6
  import android.net.Uri
6
7
  import android.os.Handler
7
8
  import android.os.Looper
@@ -12,6 +13,7 @@ import expo.modules.kotlin.AppContext
12
13
  import expo.modules.kotlin.viewevent.EventDispatcher
13
14
  import expo.modules.kotlin.views.ExpoView
14
15
  import expo.modules.libvlcplayer.enums.AudioMixingMode
16
+ import expo.modules.libvlcplayer.enums.VideoContentFit
15
17
  import expo.modules.libvlcplayer.records.Dialog
16
18
  import expo.modules.libvlcplayer.records.MediaInfo
17
19
  import expo.modules.libvlcplayer.records.MediaTracks
@@ -200,6 +202,61 @@ class LibVlcPlayerView(
200
202
  }
201
203
  }
202
204
 
205
+ fun setContentFit() {
206
+ mediaPlayer?.let { player ->
207
+ val textureView = playerView.findViewById<TextureView>(org.videolan.R.id.texture_video) ?: return
208
+ val video = player.getCurrentVideoTrack() ?: return
209
+
210
+ val viewWidth = playerView.width.toFloat()
211
+ val viewHeight = playerView.height.toFloat()
212
+
213
+ val videoWidth = video.width.toFloat()
214
+ val videoHeight = video.height.toFloat()
215
+
216
+ val viewAspect = viewWidth / viewHeight
217
+ val videoAspect = videoWidth / videoHeight
218
+
219
+ val pivotX = viewWidth / 2f
220
+ val pivotY = viewHeight / 2f
221
+
222
+ val matrix = Matrix()
223
+
224
+ when (contentFit) {
225
+ VideoContentFit.CONTAIN -> {
226
+ // No scale required
227
+ }
228
+
229
+ VideoContentFit.COVER -> {
230
+ val scale =
231
+ if (videoAspect > viewAspect) {
232
+ videoAspect / viewAspect
233
+ } else {
234
+ viewAspect / videoAspect
235
+ }
236
+
237
+ matrix.setScale(scale, scale, pivotX, pivotY)
238
+ }
239
+
240
+ VideoContentFit.FILL -> {
241
+ var scaleX = 1f
242
+ var scaleY = 1f
243
+
244
+ if (videoAspect > viewAspect) {
245
+ scaleX = 1f
246
+ scaleY = videoAspect / viewAspect
247
+ } else {
248
+ scaleX = viewAspect / videoAspect
249
+ scaleY = 1f
250
+ }
251
+
252
+ matrix.setScale(scaleX, scaleY, pivotX, pivotY)
253
+ }
254
+ }
255
+
256
+ textureView.setTransform(matrix)
257
+ }
258
+ }
259
+
203
260
  fun getMediaTracks(): MediaTracks {
204
261
  var mediaTracks = MediaTracks()
205
262
 
@@ -273,17 +330,16 @@ class LibVlcPlayerView(
273
330
  mediaPlayer?.let { player ->
274
331
  setPlayerTracks()
275
332
 
276
- if (volume != MAX_PLAYER_VOLUME || mute) {
277
- val newVolume =
278
- if (mute) {
279
- MIN_PLAYER_VOLUME
280
- } else {
281
- volume
282
- }
333
+ if (scale != DEFAULT_PLAYER_SCALE) {
334
+ player.setScale(scale)
335
+ }
283
336
 
284
- player.setVolume(newVolume)
337
+ if (aspectRatio != null) {
338
+ player.setAspectRatio(aspectRatio)
285
339
  }
286
340
 
341
+ setContentFit()
342
+
287
343
  if (rate != DEFAULT_PLAYER_RATE) {
288
344
  player.setRate(rate)
289
345
  }
@@ -292,12 +348,15 @@ class LibVlcPlayerView(
292
348
  player.setTime(time.toLong())
293
349
  }
294
350
 
295
- if (scale != DEFAULT_PLAYER_SCALE) {
296
- player.setScale(scale)
297
- }
351
+ if (volume != MAX_PLAYER_VOLUME || mute) {
352
+ val newVolume =
353
+ if (mute) {
354
+ MIN_PLAYER_VOLUME
355
+ } else {
356
+ volume
357
+ }
298
358
 
299
- if (aspectRatio != null) {
300
- player.setAspectRatio(aspectRatio)
359
+ player.setVolume(newVolume)
301
360
  }
302
361
 
303
362
  time = DEFAULT_PLAYER_TIME
@@ -347,6 +406,12 @@ class LibVlcPlayerView(
347
406
  mediaPlayer?.setAspectRatio(value)
348
407
  }
349
408
 
409
+ var contentFit: VideoContentFit = VideoContentFit.CONTAIN
410
+ set(value) {
411
+ field = value
412
+ setContentFit()
413
+ }
414
+
350
415
  var rate: Float = DEFAULT_PLAYER_RATE
351
416
  set(value) {
352
417
  field = value
@@ -487,13 +552,10 @@ class LibVlcPlayerView(
487
552
  mediaPlayer?.let { player ->
488
553
  try {
489
554
  val textureView = playerView.findViewById<TextureView>(org.videolan.R.id.texture_video) ?: throw Exception()
490
-
491
- val video = player.getCurrentVideoTrack()
492
- val width = video.width ?: 0
493
- val height = video.height ?: 0
555
+ val video = player.getCurrentVideoTrack() ?: throw Exception()
494
556
 
495
557
  val surface = Surface(textureView.surfaceTexture)
496
- val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
558
+ val bitmap = Bitmap.createBitmap(video.width, video.height, Bitmap.Config.ARGB_8888)
497
559
 
498
560
  PixelCopy.request(
499
561
  surface,
@@ -0,0 +1,11 @@
1
+ package expo.modules.libvlcplayer.enums
2
+
3
+ import expo.modules.kotlin.types.Enumerable
4
+
5
+ enum class VideoContentFit(
6
+ val value: String,
7
+ ) : Enumerable {
8
+ CONTAIN("contain"),
9
+ COVER("cover"),
10
+ FILL("fill"),
11
+ }
@@ -70,6 +70,7 @@ export interface Slave {
70
70
  type: "audio" | "subtitle";
71
71
  selected?: boolean;
72
72
  }
73
+ export type VideoContentFit = "contain" | "cover" | "fill";
73
74
  export type AudioMixingMode = "mixWithOthers" | "duckOthers" | "auto" | "doNotMix";
74
75
  export interface NativeEventProps {
75
76
  target: number;
@@ -188,6 +189,7 @@ export interface LibVlcPlayerViewNativeProps {
188
189
  slaves?: Slave[];
189
190
  scale?: number;
190
191
  aspectRatio?: string | null;
192
+ contentFit?: VideoContentFit;
191
193
  rate?: number;
192
194
  time?: number;
193
195
  volume?: number;
@@ -277,6 +279,14 @@ export interface LibVlcPlayerViewProps extends ViewProps {
277
279
  * @default undefined
278
280
  */
279
281
  aspectRatio?: string | null;
282
+ /**
283
+ * Sets how the video should be scaled to fit in the container
284
+ *
285
+ * @example "cover"
286
+ *
287
+ * @default "contain"
288
+ */
289
+ contentFit?: VideoContentFit;
280
290
  /**
281
291
  * Sets the player rate. Must be a float equal or greater than `1`
282
292
  *
@@ -1 +1 @@
1
- {"version":3,"file":"LibVlcPlayer.types.d.ts","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC;;;;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;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE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,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC5C;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IACtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC9C;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC7C;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC5C;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B"}
@@ -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 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 string 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 string\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 an integer of `1` or `2`\n *\n * @returns A promise which resolves to `void`\n */\n readonly postAction: (action: 1 | 2) => Promise<void>;\n /**\n * Dismisses a `Dialog`\n *\n * @returns A promise which resolves to `void`\n */\n readonly dismiss: () => 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 type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"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 Dialog {\n title: string;\n text: string;\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 tracks: MediaTracks;\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 EndReachedListener = () => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\ntype EncounteredErrorListener = (event: NativeEvent<Error>) => void;\n\nexport type Time = { time: number };\n\n/**\n * @hidden\n */\ntype TimeChangedListener = (event: NativeEvent<Time>) => void;\n\nexport type Position = { position: number };\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\nexport type Snapshot = { path: string };\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 */\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 repeat?: boolean;\n autoplay?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEndReached?: EndReachedListener;\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}\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 in the background\n *\n * @default false\n */\n playInBackground?: boolean;\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 * 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 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"]}
1
+ {"version":3,"file":"LibVlcPlayer.types.js","sourceRoot":"","sources":["../src/LibVlcPlayer.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps } from \"react-native\";\n\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 string 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 string\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 an integer of `1` or `2`\n *\n * @returns A promise which resolves to `void`\n */\n readonly postAction: (action: 1 | 2) => Promise<void>;\n /**\n * Dismisses a `Dialog`\n *\n * @returns A promise which resolves to `void`\n */\n readonly dismiss: () => 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 type VideoContentFit = \"contain\" | \"cover\" | \"fill\";\n\nexport type AudioMixingMode =\n | \"mixWithOthers\"\n | \"duckOthers\"\n | \"auto\"\n | \"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 Dialog {\n title: string;\n text: string;\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 tracks: MediaTracks;\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 EndReachedListener = () => void;\n\nexport type Error = { error: string };\n\n/**\n * @hidden\n */\ntype EncounteredErrorListener = (event: NativeEvent<Error>) => void;\n\nexport type Time = { time: number };\n\n/**\n * @hidden\n */\ntype TimeChangedListener = (event: NativeEvent<Time>) => void;\n\nexport type Position = { position: number };\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\nexport type Snapshot = { path: string };\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 */\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 contentFit?: VideoContentFit;\n rate?: number;\n time?: number;\n volume?: number;\n mute?: boolean;\n audioMixingMode?: AudioMixingMode;\n playInBackground?: boolean;\n repeat?: boolean;\n autoplay?: boolean;\n onBuffering?: BufferingListener;\n onPlaying?: PlayingListener;\n onPaused?: PausedListener;\n onStopped?: StoppedListener;\n onEndReached?: EndReachedListener;\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}\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 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 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 in the background\n *\n * @default false\n */\n playInBackground?: boolean;\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 * 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 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"]}
@@ -0,0 +1,7 @@
1
+ import ExpoModulesCore
2
+
3
+ enum VideoContentFit: String, Enumerable {
4
+ case contain
5
+ case cover
6
+ case fill
7
+ }
@@ -81,6 +81,10 @@ public class LibVlcPlayerModule: Module {
81
81
  view.aspectRatio = aspectRatio
82
82
  }
83
83
 
84
+ Prop("contentFit") { (view: LibVlcPlayerView, contentFit: VideoContentFit?) in
85
+ view.contentFit = contentFit ?? .contain
86
+ }
87
+
84
88
  Prop("rate") { (view: LibVlcPlayerView, rate: Float?) in
85
89
  view.rate = rate ?? defaultPlayerRate
86
90
  }
@@ -141,6 +141,49 @@ class LibVlcPlayerView: ExpoView {
141
141
  }
142
142
  }
143
143
 
144
+ func setContentFit() {
145
+ if let player = mediaPlayer {
146
+ let view = playerView.bounds.size
147
+ let video = player.videoSize
148
+
149
+ let viewAspect = view.width / view.height
150
+ let videoAspect = video.width / video.height
151
+
152
+ var transform: CGAffineTransform = .identity
153
+
154
+ switch contentFit {
155
+ case .contain:
156
+ // No transform required
157
+ break
158
+ case .cover:
159
+ var scale = 1.0
160
+
161
+ if videoAspect > viewAspect {
162
+ scale = videoAspect / viewAspect
163
+ } else {
164
+ scale = viewAspect / videoAspect
165
+ }
166
+
167
+ transform = CGAffineTransform(scaleX: scale, y: scale)
168
+ case .fill:
169
+ var scaleX = 1.0
170
+ var scaleY = 1.0
171
+
172
+ if videoAspect > viewAspect {
173
+ scaleX = 1.0
174
+ scaleY = videoAspect / viewAspect
175
+ } else {
176
+ scaleX = viewAspect / videoAspect
177
+ scaleY = 1.0
178
+ }
179
+
180
+ transform = CGAffineTransform(scaleX: scaleX, y: scaleY)
181
+ }
182
+
183
+ playerView.transform = transform
184
+ }
185
+ }
186
+
144
187
  func getMediaTracks() -> MediaTracks {
145
188
  var mediaTracks = MediaTracks()
146
189
 
@@ -218,14 +261,18 @@ class LibVlcPlayerView: ExpoView {
218
261
  if let player = mediaPlayer {
219
262
  setPlayerTracks()
220
263
 
221
- if volume != maxPlayerVolume || mute {
222
- let newVolume = mute ?
223
- minPlayerVolume :
224
- volume
264
+ if scale != defaultPlayerScale {
265
+ player.scaleFactor = scale
266
+ }
225
267
 
226
- player.audio?.volume = Int32(newVolume)
268
+ if let aspectRatio = aspectRatio {
269
+ aspectRatio.withCString { cString in
270
+ player.videoAspectRatio = UnsafeMutablePointer(mutating: cString)
271
+ }
227
272
  }
228
273
 
274
+ setContentFit()
275
+
229
276
  if rate != defaultPlayerRate {
230
277
  player.rate = rate
231
278
  }
@@ -234,14 +281,12 @@ class LibVlcPlayerView: ExpoView {
234
281
  player.time = VLCTime(int: Int32(time))
235
282
  }
236
283
 
237
- if scale != defaultPlayerScale {
238
- player.scaleFactor = scale
239
- }
284
+ if volume != maxPlayerVolume || mute {
285
+ let newVolume = mute ?
286
+ minPlayerVolume :
287
+ volume
240
288
 
241
- if let aspectRatio = aspectRatio {
242
- aspectRatio.withCString { cString in
243
- player.videoAspectRatio = UnsafeMutablePointer(mutating: cString)
244
- }
289
+ player.audio?.volume = Int32(newVolume)
245
290
  }
246
291
 
247
292
  time = defaultPlayerTime
@@ -299,6 +344,12 @@ class LibVlcPlayerView: ExpoView {
299
344
  }
300
345
  }
301
346
 
347
+ var contentFit: VideoContentFit = .contain {
348
+ didSet {
349
+ setContentFit()
350
+ }
351
+ }
352
+
302
353
  var rate: Float = defaultPlayerRate {
303
354
  didSet {
304
355
  mediaPlayer?.rate = rate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -76,6 +76,8 @@ export interface Slave {
76
76
  selected?: boolean;
77
77
  }
78
78
 
79
+ export type VideoContentFit = "contain" | "cover" | "fill";
80
+
79
81
  export type AudioMixingMode =
80
82
  | "mixWithOthers"
81
83
  | "duckOthers"
@@ -218,6 +220,7 @@ export interface LibVlcPlayerViewNativeProps {
218
220
  slaves?: Slave[];
219
221
  scale?: number;
220
222
  aspectRatio?: string | null;
223
+ contentFit?: VideoContentFit;
221
224
  rate?: number;
222
225
  time?: number;
223
226
  volume?: number;
@@ -308,6 +311,14 @@ export interface LibVlcPlayerViewProps extends ViewProps {
308
311
  * @default undefined
309
312
  */
310
313
  aspectRatio?: string | null;
314
+ /**
315
+ * Sets how the video should be scaled to fit in the container
316
+ *
317
+ * @example "cover"
318
+ *
319
+ * @default "contain"
320
+ */
321
+ contentFit?: VideoContentFit;
311
322
  /**
312
323
  * Sets the player rate. Must be a float equal or greater than `1`
313
324
  *