expo-libvlc-player 7.0.14 → 7.0.16

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.
@@ -55,7 +55,7 @@ class LibVlcPlayerView(
55
55
  ) : ExpoView(context, appContext) {
56
56
  val playerLayout: VLCVideoLayout = VLCVideoLayout(context)
57
57
  val pictureLayout: VLCVideoLayout = VLCVideoLayout(context)
58
- private var pauseIfJob: Job? = null
58
+ private var pauseCoroutine: Job? = null
59
59
 
60
60
  var libVLC: LibVLC? = null
61
61
  var mediaPlayer: MediaPlayer? = null
@@ -573,25 +573,23 @@ class LibVlcPlayerView(
573
573
  mediaPlayer?.pause()
574
574
  }
575
575
 
576
- fun pauseIf(condition: Boolean? = true) {
577
- cancelPauseIf()
576
+ fun pauseJob() {
577
+ cancelPauseJob()
578
578
 
579
- pauseIfJob =
579
+ pauseCoroutine =
580
580
  CoroutineScope(Dispatchers.Main).launch {
581
- delay(MediaPlayerConstants.COROUTINE_DELAY_MS)
582
-
583
- mediaPlayer?.let { player ->
584
- val shouldPause = condition == true && player.isPlaying()
581
+ if (pictureInPicture) {
582
+ delay(MediaPlayerConstants.COROUTINE_DELAY_MS)
583
+ }
585
584
 
586
- if (shouldPause) {
587
- player.pause()
588
- }
585
+ if (isInBackground) {
586
+ mediaPlayer?.pause()
589
587
  }
590
588
  }
591
589
  }
592
590
 
593
- fun cancelPauseIf() {
594
- pauseIfJob?.cancel()
591
+ fun cancelPauseJob() {
592
+ pauseCoroutine?.cancel()
595
593
  }
596
594
 
597
595
  fun stop() {
@@ -725,7 +723,7 @@ class LibVlcPlayerView(
725
723
  delay: Double = MediaPlayerConstants.RETRY_DELAY_MS,
726
724
  block: (isLastAttempt: Boolean) -> Boolean,
727
725
  ) {
728
- val isLastAttempt = retry >= maxRetries
726
+ val isLastAttempt = retry > maxRetries
729
727
 
730
728
  if (block(isLastAttempt) || isLastAttempt) return
731
729
 
@@ -15,8 +15,8 @@ object MediaPlayerConstants {
15
15
  const val EXTRA_CONTROL_FORWARD: Int = 4
16
16
  const val SEEK_STEP_MS: Long = 10_000L
17
17
 
18
- const val COROUTINE_DELAY_MS: Long = 1_000L
18
+ const val COROUTINE_DELAY_MS: Long = 750L
19
19
  const val EXP_DELAY_MULTIPLIER: Double = 1.5
20
- const val RETRY_DELAY_MS: Double = 200.0
21
- const val MAX_RETRY_COUNT: Int = 5
20
+ const val RETRY_DELAY_MS: Double = 300.0
21
+ const val MAX_RETRY_COUNT: Int = 3
22
22
  }
@@ -42,17 +42,17 @@ object MediaPlayerManager {
42
42
 
43
43
  fun onModuleForeground() {
44
44
  expoViews.forEach { view ->
45
- view.onForeground(Unit)
46
- view.cancelPauseIf()
47
45
  view.isInBackground = false
46
+ view.onForeground(Unit)
47
+ view.cancelPauseJob()
48
48
  }
49
49
  }
50
50
 
51
51
  fun onModuleBackground() {
52
52
  expoViews.forEach { view ->
53
- view.onBackground(Unit)
54
- view.pauseIf()
55
53
  view.isInBackground = true
54
+ view.onBackground(Unit)
55
+ view.pauseJob()
56
56
  }
57
57
  }
58
58
  }
@@ -17,10 +17,10 @@ class PictureInPictureFragment(
17
17
  expoView.get()?.let { view ->
18
18
  if (isInPictureInPictureMode) {
19
19
  view.onStartPictureInPicture()
20
- view.cancelPauseIf()
20
+ view.cancelPauseJob()
21
21
  } else {
22
22
  view.onStopPictureInPicture()
23
- view.pauseIf(view.isInBackground)
23
+ view.pauseJob()
24
24
  }
25
25
  }
26
26
  }
@@ -6,6 +6,6 @@ enum MediaPlayerConstants {
6
6
  static let maxPlayerVolume: Int = 100
7
7
 
8
8
  static let expDelayMultiplier: Double = 1.5
9
- static let retryDelayMs: Double = 200.0
10
- static let maxRetryCount: Int = 5
9
+ static let retryDelayMs: Double = 300.0
10
+ static let maxRetryCount: Int = 3
11
11
  }
@@ -436,13 +436,9 @@ class LibVlcPlayerView: ExpoView {
436
436
  mediaPlayer?.pause()
437
437
  }
438
438
 
439
- func pauseIf(_ condition: Bool? = true) {
440
- if let player = mediaPlayer {
441
- let shouldPause = condition == true && player.isPlaying
442
-
443
- if shouldPause {
444
- player.pause()
445
- }
439
+ func pausePip() {
440
+ if !pictureInPicture {
441
+ mediaPlayer?.pause()
446
442
  }
447
443
  }
448
444
 
@@ -557,7 +553,7 @@ class LibVlcPlayerView: ExpoView {
557
553
  delay: Double = MediaPlayerConstants.retryDelayMs,
558
554
  block: @escaping (_ isLastAttempt: Bool) -> Bool
559
555
  ) {
560
- let isLastAttempt = retry >= maxRetries
556
+ let isLastAttempt = retry > maxRetries
561
557
 
562
558
  if block(isLastAttempt) || isLastAttempt { return }
563
559
 
@@ -25,16 +25,16 @@ class MediaPlayerManager {
25
25
 
26
26
  func onModuleForeground() {
27
27
  for view in expoViews.allObjects {
28
- view.onForeground()
29
28
  view.isInBackground = false
29
+ view.onForeground()
30
30
  }
31
31
  }
32
32
 
33
33
  func onModuleBackground() {
34
34
  for view in expoViews.allObjects {
35
- view.onBackground()
36
- view.pauseIf(!view.pictureInPicture)
37
35
  view.isInBackground = true
36
+ view.onBackground()
37
+ view.pausePip()
38
38
  }
39
39
  }
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "7.0.14",
3
+ "version": "7.0.16",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",