expo-libvlc-player 3.4.16 → 3.4.18

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.
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'expo.modules.libvlcplayer'
4
- version = '3.4.16'
4
+ version = '3.4.18'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(':expo-modules-core').projectDir.absolutePath, 'ExpoModulesCorePlugin.gradle')
7
7
  apply from: expoModulesCorePlugin
@@ -25,7 +25,7 @@ android {
25
25
  targetSdkVersion safeExtGet('targetSdkVersion', 35)
26
26
 
27
27
  versionCode 1
28
- versionName '3.4.16'
28
+ versionName '3.4.18'
29
29
 
30
30
  consumerProguardFiles('proguard-rules.pro')
31
31
  }
@@ -310,10 +310,10 @@ class LibVlcPlayerView(
310
310
 
311
311
  mediaPlayer?.let { player ->
312
312
  val video = player.getCurrentVideoTrack()
313
- val pLength = player.getLength()
313
+ val duration = player.getLength()
314
314
  val length =
315
- if (pLength != -1L) {
316
- pLength
315
+ if (duration != -1L) {
316
+ duration
317
317
  } else {
318
318
  0L
319
319
  }
@@ -373,14 +373,12 @@ class LibVlcPlayerView(
373
373
 
374
374
  var source: String? = null
375
375
  set(value) {
376
- val old = field
377
376
  field = value
378
377
  shouldCreate = true
379
378
  }
380
379
 
381
380
  var options: MutableList<String> = mutableListOf()
382
381
  set(value) {
383
- val old = field
384
382
  field = value
385
383
  shouldCreate = true
386
384
  }
@@ -514,10 +512,6 @@ class LibVlcPlayerView(
514
512
 
515
513
  fun record(path: String?) {
516
514
  mediaPlayer?.let { player ->
517
- if (!player.isPlaying()) {
518
- return
519
- }
520
-
521
515
  if (path != null) {
522
516
  val success = player.record(path)
523
517
 
@@ -563,7 +557,7 @@ class LibVlcPlayerView(
563
557
  Handler(Looper.getMainLooper()),
564
558
  )
565
559
  } catch (_: Exception) {
566
- onEncounteredError(mapOf("error" to "Media snapshot could not be taken"))
560
+ onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
567
561
  }
568
562
  }
569
563
  }
@@ -643,13 +637,9 @@ fun LibVlcPlayerView.setMediaPlayerListener() {
643
637
  }
644
638
 
645
639
  Event.EncounteredError -> {
646
- onEncounteredError(mapOf("error" to "Media player encountered an error"))
647
-
648
- MediaPlayerManager.keepAwakeManager.deactivateKeepAwake()
649
- MediaPlayerManager.audioFocusManager.updateAudioFocus()
640
+ onEncounteredError(mapOf("error" to "Player encountered an error"))
650
641
 
651
- firstPlay = true
652
- firstTime = true
642
+ player.stop()
653
643
  }
654
644
 
655
645
  Event.TimeChanged -> {
@@ -403,7 +403,7 @@ class LibVlcPlayerView: ExpoView {
403
403
  }
404
404
 
405
405
  func record(_ path: String?) {
406
- if let player = mediaPlayer, player.isPlaying {
406
+ if let player = mediaPlayer {
407
407
  if let path {
408
408
  // https://code.videolan.org/videolan/VLCKit/-/issues/394
409
409
  let success = !player.startRecording(atPath: path)
@@ -421,19 +421,20 @@ class LibVlcPlayerView: ExpoView {
421
421
 
422
422
  func snapshot(_ path: String) {
423
423
  if let player = mediaPlayer {
424
- let dateFormatter = DateFormatter()
425
- dateFormatter.dateFormat = "yyyy-MM-dd-HH'h'mm'm'ss's'"
426
- let snapshotPath = path + "/vlc-snapshot-\(dateFormatter.string(from: Date())).jpg"
427
-
428
424
  let video = player.videoSize
429
- let width = Int32(video.width)
430
- let height = Int32(video.height)
431
425
 
432
- player.saveVideoSnapshot(at: snapshotPath, withWidth: width, andHeight: height)
426
+ if video != .zero {
427
+ let dateFormatter = DateFormatter()
428
+ dateFormatter.dateFormat = "yyyy-MM-dd-HH'h'mm'm'ss's'"
429
+ let snapshotPath = path + "/vlc-snapshot-\(dateFormatter.string(from: Date())).jpg"
430
+
431
+ player.saveVideoSnapshot(at: snapshotPath, withWidth: Int32(video.width), andHeight: Int32(video.height))
433
432
 
434
- onSnapshotTaken(["path": snapshotPath])
435
- } else {
436
- onEncounteredError(["error": "Media snapshot could not be taken"])
433
+ onSnapshotTaken(["path": snapshotPath])
434
+ } else {
435
+ onEncounteredError(["error": "Snapshot could not be taken"])
436
+ return
437
+ }
437
438
  }
438
439
  }
439
440
 
@@ -493,13 +494,9 @@ extension LibVlcPlayerView: VLCMediaPlayerDelegate {
493
494
  player.play()
494
495
  }
495
496
  case .error:
496
- onEncounteredError(["error": "Media player encountered an error"])
497
+ onEncounteredError(["error": "Player encountered an error"])
497
498
 
498
- MediaPlayerManager.shared.keepAwakeManager.deactivateKeepAwake()
499
- MediaPlayerManager.shared.audioSessionManager.setAppropriateAudioSession()
500
-
501
- firstPlay = true
502
- firstTime = true
499
+ player.stop()
503
500
  case .esAdded:
504
501
  onESAdded(getMediaTracks())
505
502
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "3.4.16",
3
+ "version": "3.4.18",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",