expo-libvlc-player 7.0.15 → 7.0.17

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() {
@@ -15,7 +15,7 @@ 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 = 750L
18
+ const val COROUTINE_DELAY_MS: Long = 1_000L
19
19
  const val EXP_DELAY_MULTIPLIER: Double = 1.5
20
20
  const val RETRY_DELAY_MS: Double = 300.0
21
21
  const val MAX_RETRY_COUNT: Int = 3
@@ -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(!view.pictureInPicture)
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
  }
@@ -5,6 +5,7 @@ enum MediaPlayerConstants {
5
5
  static let minPlayerVolume: Int = 0
6
6
  static let maxPlayerVolume: Int = 100
7
7
 
8
+ static let pipDelayMs: Double = 1_000.0
8
9
  static let expDelayMultiplier: Double = 1.5
9
10
  static let retryDelayMs: Double = 300.0
10
11
  static let maxRetryCount: Int = 3
@@ -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
 
@@ -534,12 +530,19 @@ class LibVlcPlayerView: ExpoView {
534
530
 
535
531
  func resetPictureInPicture() {
536
532
  guard let player = mediaPlayer,
537
- let videoTrack = player.videoTracks.first(where: { track in track.isSelected }),
538
- isInBackground else { return }
533
+ let videoTrack = player.videoTracks.first(where: { track in track.isSelected })
534
+ else { return }
539
535
 
536
+ videoTrack.isSelected = false
540
537
  videoTrack.isSelectedExclusively = true
538
+
541
539
  player.play()
542
- player.pause()
540
+
541
+ let deadline = DispatchTime.now() + .milliseconds(Int(MediaPlayerConstants.pipDelayMs))
542
+
543
+ DispatchQueue.main.asyncAfter(deadline: deadline) {
544
+ player.pause()
545
+ }
543
546
  }
544
547
 
545
548
  func onStartPictureInPicture() {
@@ -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.15",
3
+ "version": "7.0.17",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "@types/react": "^19.2.14",
37
37
  "eslint": "^9.39.4",
38
38
  "eslint-config-universe": "^15.0.3",
39
- "expo": "~55.0.18",
39
+ "expo": "~55.0.19",
40
40
  "husky": "^9.1.7",
41
41
  "lint-staged": "^16.4.0",
42
42
  "prettier": "^3.8.3",