expo-libvlc-player 6.1.12 → 6.1.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.
@@ -290,50 +290,48 @@ class LibVlcPlayerView(
290
290
  val view = getTextureView(layout) ?: return@post
291
291
  val matrix = Matrix()
292
292
 
293
- mediaPlayer?.let { player ->
294
- val video = getVideoSize()
293
+ val video = getVideoSize()
295
294
 
296
- if (hasVideoSize) {
297
- val viewWidth = view.width.toFloat()
298
- val viewHeight = view.height.toFloat()
295
+ if (hasVideoSize) {
296
+ val viewWidth = view.width.toFloat()
297
+ val viewHeight = view.height.toFloat()
299
298
 
300
- val videoWidth = video.width.toFloat()
301
- val videoHeight = video.height.toFloat()
299
+ val videoWidth = video.width.toFloat()
300
+ val videoHeight = video.height.toFloat()
302
301
 
303
- val viewAspect = viewWidth / viewHeight
304
- val videoAspect = videoWidth / videoHeight
302
+ val viewAspect = viewWidth / viewHeight
303
+ val videoAspect = videoWidth / videoHeight
305
304
 
306
- val pivotX = viewWidth / 2f
307
- val pivotY = viewHeight / 2f
305
+ val pivotX = viewWidth / 2f
306
+ val pivotY = viewHeight / 2f
308
307
 
309
- when (contentFit) {
310
- VideoContentFit.CONTAIN -> {
311
- // No scale required
312
- }
313
-
314
- VideoContentFit.COVER -> {
315
- val scale =
316
- if (videoAspect > viewAspect) {
317
- videoAspect / viewAspect
318
- } else {
319
- viewAspect / videoAspect
320
- }
321
-
322
- matrix.setScale(scale, scale, pivotX, pivotY)
323
- }
324
-
325
- VideoContentFit.FILL -> {
326
- var scaleX = 1f
327
- var scaleY = 1f
308
+ when (contentFit) {
309
+ VideoContentFit.CONTAIN -> {
310
+ // No scale required
311
+ }
328
312
 
313
+ VideoContentFit.COVER -> {
314
+ val scale =
329
315
  if (videoAspect > viewAspect) {
330
- scaleY = videoAspect / viewAspect
316
+ videoAspect / viewAspect
331
317
  } else {
332
- scaleX = viewAspect / videoAspect
318
+ viewAspect / videoAspect
333
319
  }
334
320
 
335
- matrix.setScale(scaleX, scaleY, pivotX, pivotY)
321
+ matrix.setScale(scale, scale, pivotX, pivotY)
322
+ }
323
+
324
+ VideoContentFit.FILL -> {
325
+ var scaleX = 1f
326
+ var scaleY = 1f
327
+
328
+ if (videoAspect > viewAspect) {
329
+ scaleY = videoAspect / viewAspect
330
+ } else {
331
+ scaleX = viewAspect / videoAspect
336
332
  }
333
+
334
+ matrix.setScale(scaleX, scaleY, pivotX, pivotY)
337
335
  }
338
336
  }
339
337
  }
@@ -417,12 +415,10 @@ class LibVlcPlayerView(
417
415
  fun getMediaLength(): Long {
418
416
  var length: Long = 0L
419
417
 
420
- mediaPlayer?.let { player ->
421
- val duration = player.getLength()
418
+ val duration = mediaPlayer?.getLength() ?: 0L
422
419
 
423
- if (duration > 0L) {
424
- length = duration
425
- }
420
+ if (duration > 0L) {
421
+ length = duration
426
422
  }
427
423
 
428
424
  return length
@@ -431,19 +427,17 @@ class LibVlcPlayerView(
431
427
  fun getMediaInfo(): MediaInfo {
432
428
  var mediaInfo = MediaInfo()
433
429
 
434
- mediaPlayer?.let { player ->
435
- val video = getVideoSize()
436
- val length = getMediaLength()
437
- val seekable = player.isSeekable()
438
-
439
- mediaInfo =
440
- MediaInfo(
441
- width = video.width,
442
- height = video.height,
443
- length = length.toDouble(),
444
- seekable = seekable,
445
- )
446
- }
430
+ val video = getVideoSize()
431
+ val length = getMediaLength()
432
+ val seekable = mediaPlayer?.isSeekable() ?: false
433
+
434
+ mediaInfo =
435
+ MediaInfo(
436
+ width = video.width,
437
+ height = video.height,
438
+ length = length.toDouble(),
439
+ seekable = seekable,
440
+ )
447
441
 
448
442
  return mediaInfo
449
443
  }
@@ -655,24 +649,25 @@ class LibVlcPlayerView(
655
649
  }
656
650
 
657
651
  fun snapshot(path: String) {
658
- mediaPlayer?.let { player ->
659
- try {
660
- val view = getTextureView(playerLayout) ?: throw Exception()
661
-
662
- if (!hasVideoSize) throw Exception()
652
+ try {
653
+ val view = getTextureView(playerLayout) ?: throw Exception()
663
654
 
664
- val surface = Surface(view.surfaceTexture)
665
- val video = getVideoSize()
666
- val bitmap = Bitmap.createBitmap(video.width, video.height, Bitmap.Config.ARGB_8888)
655
+ if (!hasVideoSize) throw Exception()
667
656
 
668
- PixelCopy.request(
669
- surface,
670
- bitmap,
671
- { copyResult ->
672
- if (copyResult != PixelCopy.SUCCESS) {
673
- onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
674
- }
657
+ val surface = Surface(view.surfaceTexture)
658
+ val video = getVideoSize()
659
+ val bitmap = Bitmap.createBitmap(video.width, video.height, Bitmap.Config.ARGB_8888)
660
+
661
+ PixelCopy.request(
662
+ surface,
663
+ bitmap,
664
+ { copyResult ->
665
+ if (copyResult != PixelCopy.SUCCESS) {
666
+ onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
667
+ return@request
668
+ }
675
669
 
670
+ try {
676
671
  val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd-HH'h'mm'm'ss's'")
677
672
  val timestamp = simpleDateFormat.format(Calendar.getInstance().time)
678
673
 
@@ -684,12 +679,14 @@ class LibVlcPlayerView(
684
679
  }
685
680
 
686
681
  onSnapshotTaken(mapOf("path" to snapshotPath))
687
- },
688
- Handler(Looper.getMainLooper()),
689
- )
690
- } catch (_: Exception) {
691
- onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
692
- }
682
+ } catch (_: Exception) {
683
+ onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
684
+ }
685
+ },
686
+ Handler(Looper.getMainLooper()),
687
+ )
688
+ } catch (_: Exception) {
689
+ onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
693
690
  }
694
691
  }
695
692
 
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
19
19
  s.static_framework = true
20
20
 
21
21
  s.dependency 'ExpoModulesCore'
22
- s.dependency 'VLCKit', '4.0.0a18'
22
+ s.dependency 'VLCKit', '4.0.0a19'
23
23
 
24
24
  # Swift/Objective-C compatibility
25
25
  s.pod_target_xcconfig = {
@@ -250,12 +250,10 @@ class LibVlcPlayerView: ExpoView {
250
250
  func getMediaLength() -> Int32 {
251
251
  var length: Int32 = 0
252
252
 
253
- if let player = mediaPlayer, let media = player.media {
254
- let duration = media.length.intValue
253
+ let duration = mediaPlayer?.media?.length.intValue ?? 0
255
254
 
256
- if duration > 0 {
257
- length = duration
258
- }
255
+ if duration > 0 {
256
+ length = duration
259
257
  }
260
258
 
261
259
  return length
@@ -296,18 +294,16 @@ class LibVlcPlayerView: ExpoView {
296
294
  func getMediaInfo() -> MediaInfo {
297
295
  var mediaInfo = MediaInfo()
298
296
 
299
- if let player = mediaPlayer {
300
- let video = getVideoSize()
301
- let length = getMediaLength()
302
- let seekable = player.isSeekable
303
-
304
- mediaInfo = MediaInfo(
305
- width: Int(video.width),
306
- height: Int(video.height),
307
- length: Double(length),
308
- seekable: seekable
309
- )
310
- }
297
+ let video = getVideoSize()
298
+ let length = getMediaLength()
299
+ let seekable = mediaPlayer?.isSeekable ?? false
300
+
301
+ mediaInfo = MediaInfo(
302
+ width: Int(video.width),
303
+ height: Int(video.height),
304
+ length: Double(length),
305
+ seekable: seekable
306
+ )
311
307
 
312
308
  return mediaInfo
313
309
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "6.1.12",
3
+ "version": "6.1.14",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",