expo-libvlc-player 7.0.15 → 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() {
@@ -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
  }
@@ -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
 
@@ -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.16",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",