expo-libvlc-player 7.0.19 → 7.0.21

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.
package/README.md CHANGED
@@ -287,15 +287,15 @@ interface MediaInfo {
287
287
 
288
288
  #### Black screen
289
289
 
290
- On Android, the `libvlcjni` player detaches from the View when its surface is destroyed after switching screens.
290
+ On Android, the `libvlcjni` player detaches from the View after switching screens.
291
291
 
292
- The current workaround attaches the View once a surface is created but this causes a brief black screen.
292
+ The current workaround attaches the View back but it causes a brief black screen.
293
293
 
294
294
  https://code.videolan.org/videolan/vlc-android/-/issues/1495
295
295
 
296
- On iOS, the `VLCKit` player deallocates from the UIView when closing the Picture-in-Picture (PiP) window.
296
+ On iOS, the `VLCKit` player deselects the video track after switching screens.
297
297
 
298
- The current workaround exclusively selects the current video track but this causes a brief black screen.
298
+ The current workaround selects the video track back but it causes a brief black screen.
299
299
 
300
300
  https://code.videolan.org/videolan/VLCKit/-/issues/743
301
301
 
@@ -63,7 +63,6 @@ class LibVlcPlayerView(
63
63
 
64
64
  var firstPlay: Boolean = true
65
65
  private var shouldInit: Boolean = true
66
- var isInBackground: Boolean = false
67
66
 
68
67
  val onBuffering by EventDispatcher<Unit>()
69
68
  val onPlaying by EventDispatcher<Unit>()
@@ -42,7 +42,6 @@ object MediaPlayerManager {
42
42
 
43
43
  fun onModuleForeground() {
44
44
  expoViews.forEach { view ->
45
- view.isInBackground = false
46
45
  view.onForeground(Unit)
47
46
  view.cancelPauseJob()
48
47
  }
@@ -50,7 +49,6 @@ object MediaPlayerManager {
50
49
 
51
50
  fun onModuleBackground() {
52
51
  expoViews.forEach { view ->
53
- view.isInBackground = true
54
52
  view.onBackground(Unit)
55
53
  view.pauseJob()
56
54
  }
@@ -307,15 +307,6 @@ class LibVlcPlayerView: ExpoView {
307
307
 
308
308
  videoTrack.isSelected = false
309
309
  videoTrack.isSelectedExclusively = true
310
-
311
- // Black screen workaround
312
- let delay = DispatchTimeInterval.milliseconds(Int(MediaPlayerConstants.resetDelayMs))
313
- let deadline = DispatchTime.now() + delay
314
- let time = VLCTime(int: Int32(player.time.intValue))
315
-
316
- DispatchQueue.main.asyncAfter(deadline: deadline) {
317
- player.time = time
318
- }
319
310
  }
320
311
 
321
312
  var hasVideoSize: Bool {
@@ -479,6 +470,15 @@ class LibVlcPlayerView: ExpoView {
479
470
  }
480
471
  }
481
472
 
473
+ func seekZero() {
474
+ guard let player = mediaPlayer,
475
+ !player.isPlaying
476
+ else { return }
477
+
478
+ // Black screen workaround
479
+ player.time = VLCTime(int: Int32(player.time.intValue))
480
+ }
481
+
482
482
  func record(_ path: String?) {
483
483
  if let player = mediaPlayer {
484
484
  if let path {
@@ -20,7 +20,7 @@ class AudioSessionManager {
20
20
  let audioMixingMode = findAudioMixingMode()
21
21
  var audioSessionCategoryOptions: AVAudioSession.CategoryOptions = audioSession.categoryOptions
22
22
 
23
- let isOutputtingAudio = expoViews.allObjects.contains { view in
23
+ let anyPlayingView = expoViews.allObjects.contains { view in
24
24
  if let player = view.mediaPlayer, let audio = player.audio {
25
25
  player.isPlaying && audio.volume > MediaPlayerConstants.minPlayerVolume
26
26
  } else {
@@ -30,9 +30,9 @@ class AudioSessionManager {
30
30
 
31
31
  let shouldMixOverride = audioMixingMode == .mixWithOthers
32
32
  let doNotMixOverride = audioMixingMode == .doNotMix
33
- let shouldDuckOthers = audioMixingMode == .duckOthers && isOutputtingAudio
33
+ let shouldDuckOthers = audioMixingMode == .duckOthers && anyPlayingView
34
34
 
35
- let shouldMixWithOthers = shouldMixOverride || !isOutputtingAudio
35
+ let shouldMixWithOthers = shouldMixOverride || !anyPlayingView
36
36
 
37
37
  if shouldMixWithOthers && !shouldDuckOthers && !doNotMixOverride {
38
38
  audioSessionCategoryOptions.insert(.mixWithOthers)
@@ -54,7 +54,7 @@ class AudioSessionManager {
54
54
  }
55
55
  }
56
56
 
57
- if isOutputtingAudio || doNotMixOverride {
57
+ if anyPlayingView || doNotMixOverride {
58
58
  do {
59
59
  try audioSession.setActive(true)
60
60
  } catch {
@@ -1,9 +1,7 @@
1
1
  class KeepAwakeManager {
2
2
  static let shared = KeepAwakeManager()
3
3
 
4
- private lazy var anyPlayingView = MediaPlayerManager.shared.expoViews.allObjects.contains { view in
5
- view.mediaPlayer?.isPlaying == true
6
- }
4
+ private lazy var expoViews = MediaPlayerManager.shared.expoViews
7
5
 
8
6
  func activateKeepAwake() {
9
7
  DispatchQueue.main.async {
@@ -18,6 +16,10 @@ class KeepAwakeManager {
18
16
  }
19
17
 
20
18
  func toggleKeepAwake() {
19
+ let anyPlayingView = expoViews.allObjects.contains { view in
20
+ view.mediaPlayer?.isPlaying == true
21
+ }
22
+
21
23
  if anyPlayingView {
22
24
  activateKeepAwake()
23
25
  } else {
@@ -27,6 +27,7 @@ class MediaPlayerManager {
27
27
  for view in expoViews.allObjects {
28
28
  view.isInBackground = false
29
29
  view.onForeground()
30
+ view.seekZero()
30
31
  }
31
32
  }
32
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libvlc-player",
3
- "version": "7.0.19",
3
+ "version": "7.0.21",
4
4
  "description": "LibVLC Player for Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",