expo-libvlc-player 6.1.3 → 6.1.4
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.
|
@@ -419,14 +419,14 @@ class LibVlcPlayerView(
|
|
|
419
419
|
var mediaInfo = MediaInfo()
|
|
420
420
|
|
|
421
421
|
mediaPlayer?.let { player ->
|
|
422
|
-
val video =
|
|
422
|
+
val video = getVideoSize()
|
|
423
423
|
val length = getMediaLength()
|
|
424
424
|
val seekable = player.isSeekable()
|
|
425
425
|
|
|
426
426
|
mediaInfo =
|
|
427
427
|
MediaInfo(
|
|
428
|
-
width = video
|
|
429
|
-
height = video
|
|
428
|
+
width = video.width,
|
|
429
|
+
height = video.height,
|
|
430
430
|
length = length.toDouble(),
|
|
431
431
|
seekable = seekable,
|
|
432
432
|
)
|
|
@@ -445,6 +445,12 @@ class LibVlcPlayerView(
|
|
|
445
445
|
return Size(0, 0)
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
val hasVideoSize: Boolean
|
|
449
|
+
get() {
|
|
450
|
+
val video = getVideoSize()
|
|
451
|
+
return video.width > 0 && video.height > 0
|
|
452
|
+
}
|
|
453
|
+
|
|
448
454
|
val hasVideoOut: Boolean
|
|
449
455
|
get() {
|
|
450
456
|
val tracks = getMediaTracks()
|
|
@@ -453,10 +459,12 @@ class LibVlcPlayerView(
|
|
|
453
459
|
return hasVideo && hasVideoSize && length > 0L
|
|
454
460
|
}
|
|
455
461
|
|
|
456
|
-
val
|
|
462
|
+
val hasAudioOut: Boolean
|
|
457
463
|
get() {
|
|
458
|
-
val
|
|
459
|
-
|
|
464
|
+
val tracks = getMediaTracks()
|
|
465
|
+
val hasAudio = tracks.audio.any { track -> track.id != -1 }
|
|
466
|
+
val volume = mediaPlayer?.getVolume() ?: MediaPlayerConstants.MIN_PLAYER_VOLUME
|
|
467
|
+
return hasAudio && volume > MediaPlayerConstants.MIN_PLAYER_VOLUME
|
|
460
468
|
}
|
|
461
469
|
|
|
462
470
|
var source: String? = null
|
|
@@ -745,9 +753,7 @@ fun LibVlcPlayerView.setPlayerListener(mediaPlayer: MediaPlayer?) {
|
|
|
745
753
|
firstPlay = false
|
|
746
754
|
|
|
747
755
|
retryUntil { isLastAttempt ->
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
if (shouldSendEvent) {
|
|
756
|
+
if (hasVideoOut || isLastAttempt) {
|
|
751
757
|
onFirstPlay(getMediaInfo())
|
|
752
758
|
}
|
|
753
759
|
|
|
@@ -755,9 +761,7 @@ fun LibVlcPlayerView.setPlayerListener(mediaPlayer: MediaPlayer?) {
|
|
|
755
761
|
}
|
|
756
762
|
|
|
757
763
|
retryUntil { isLastAttempt ->
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
if (shouldFitContent) {
|
|
764
|
+
if (hasVideoSize) {
|
|
761
765
|
setContentFit(layout = playerLayout)
|
|
762
766
|
setContentFit(layout = pictureLayout)
|
|
763
767
|
}
|
|
@@ -785,15 +789,11 @@ fun LibVlcPlayerView.setPlayerListener(mediaPlayer: MediaPlayer?) {
|
|
|
785
789
|
MediaPlayerManager.keepAwakeManager.toggleKeepAwake()
|
|
786
790
|
|
|
787
791
|
retryUntil { isLastAttempt ->
|
|
788
|
-
|
|
789
|
-
val hasVolume = volume > MediaPlayerConstants.MIN_PLAYER_VOLUME
|
|
790
|
-
val shouldUpdateFocus = hasVolume || isLastAttempt
|
|
791
|
-
|
|
792
|
-
if (shouldUpdateFocus) {
|
|
792
|
+
if (hasAudioOut) {
|
|
793
793
|
MediaPlayerManager.audioFocusManager.updateAudioFocus()
|
|
794
794
|
}
|
|
795
795
|
|
|
796
|
-
return@retryUntil
|
|
796
|
+
return@retryUntil hasAudioOut
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
|
|
@@ -291,7 +291,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
291
291
|
var mediaInfo = MediaInfo()
|
|
292
292
|
|
|
293
293
|
if let player = mediaPlayer {
|
|
294
|
-
let video =
|
|
294
|
+
let video = getVideoSize()
|
|
295
295
|
let length = getMediaLength()
|
|
296
296
|
let seekable = player.isSeekable
|
|
297
297
|
|
|
@@ -307,10 +307,15 @@ class LibVlcPlayerView: ExpoView {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
func getVideoSize() -> CGSize {
|
|
310
|
-
if let
|
|
310
|
+
if let size = mediaPlayer?.videoSize { return size }
|
|
311
311
|
return CGSize(width: 0, height: 0)
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
var hasVideoSize: Bool {
|
|
315
|
+
let video = getVideoSize()
|
|
316
|
+
return video.width > 0 && video.height > 0
|
|
317
|
+
}
|
|
318
|
+
|
|
314
319
|
var hasVideoOut: Bool {
|
|
315
320
|
let tracks = getMediaTracks()
|
|
316
321
|
let length = getMediaLength()
|
|
@@ -318,9 +323,11 @@ class LibVlcPlayerView: ExpoView {
|
|
|
318
323
|
return hasVideo && hasVideoSize && length > 0
|
|
319
324
|
}
|
|
320
325
|
|
|
321
|
-
var
|
|
322
|
-
let
|
|
323
|
-
|
|
326
|
+
var hasAudioOut: Bool {
|
|
327
|
+
let tracks = getMediaTracks()
|
|
328
|
+
let hasAudio = tracks.audio.count > 0
|
|
329
|
+
let volume = mediaPlayer?.audio?.volume ?? Int32(MediaPlayerConstants.minPlayerVolume)
|
|
330
|
+
return hasAudio && volume > MediaPlayerConstants.minPlayerVolume
|
|
324
331
|
}
|
|
325
332
|
|
|
326
333
|
var source: String? {
|
|
@@ -569,21 +576,17 @@ extension LibVlcPlayerView: VLCMediaPlayerDelegate {
|
|
|
569
576
|
retryUntil { [weak self] isLastAttempt in
|
|
570
577
|
guard let self else { return true }
|
|
571
578
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
if shouldSendEvent {
|
|
579
|
+
if hasVideoOut || isLastAttempt {
|
|
575
580
|
onFirstPlay(getMediaInfo())
|
|
576
581
|
}
|
|
577
582
|
|
|
578
583
|
return hasVideoOut
|
|
579
584
|
}
|
|
580
585
|
|
|
581
|
-
retryUntil { [weak self]
|
|
586
|
+
retryUntil { [weak self] _ in
|
|
582
587
|
guard let self else { return true }
|
|
583
588
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
if shouldFitContent {
|
|
589
|
+
if hasVideoSize {
|
|
587
590
|
setContentFit(drawable: playerDrawable)
|
|
588
591
|
setContentFit(drawable: pictureDrawable)
|
|
589
592
|
}
|
|
@@ -608,16 +611,14 @@ extension LibVlcPlayerView: VLCMediaPlayerDelegate {
|
|
|
608
611
|
pictureDrawable.updatePipState()
|
|
609
612
|
MediaPlayerManager.shared.keepAwakeManager.toggleKeepAwake()
|
|
610
613
|
|
|
611
|
-
retryUntil {
|
|
612
|
-
let
|
|
613
|
-
let hasVolume = volume > MediaPlayerConstants.minPlayerVolume
|
|
614
|
-
let shouldUpdateSession = hasVolume || isLastAttempt
|
|
614
|
+
retryUntil { [weak self] _ in
|
|
615
|
+
guard let self else { return true }
|
|
615
616
|
|
|
616
|
-
if
|
|
617
|
+
if hasAudioOut {
|
|
617
618
|
MediaPlayerManager.shared.audioSessionManager.setAppropriateAudioSession()
|
|
618
619
|
}
|
|
619
620
|
|
|
620
|
-
return
|
|
621
|
+
return hasAudioOut
|
|
621
622
|
}
|
|
622
623
|
case .error:
|
|
623
624
|
onEncounteredError(["error": "Player encountered an error"])
|