expo-libvlc-player 6.1.6 → 6.1.8
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/android/src/main/java/expo/modules/libvlcplayer/LibVlcPlayerView.kt +18 -8
- package/android/src/main/java/expo/modules/libvlcplayer/managers/PictureInPictureManager.kt +14 -7
- package/ios/LibVlcPlayerView.swift +6 -5
- package/ios/Utils/MediaPlayerDrawable.swift +1 -0
- package/ios/Utils/PictureInPictureDrawable.swift +1 -1
- package/package.json +1 -1
|
@@ -127,7 +127,7 @@ class LibVlcPlayerView(
|
|
|
127
127
|
args.toggleStartPausedOption(autoplay)
|
|
128
128
|
|
|
129
129
|
if (pictureInPicture) {
|
|
130
|
-
MediaPlayerManager.pictureInPictureManager.
|
|
130
|
+
MediaPlayerManager.pictureInPictureManager.setupPipView(this)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
libVLC = LibVLC(context, args)
|
|
@@ -216,26 +216,36 @@ class LibVlcPlayerView(
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
fun selectTrack(
|
|
219
|
-
|
|
219
|
+
trackId: Int?,
|
|
220
220
|
type: Int,
|
|
221
221
|
) {
|
|
222
222
|
mediaPlayer?.let { player ->
|
|
223
|
+
val tracks =
|
|
224
|
+
when (type) {
|
|
225
|
+
IMedia.Track.Type.Audio -> player.getAudioTracks()
|
|
226
|
+
IMedia.Track.Type.Video -> player.getVideoTracks()
|
|
227
|
+
IMedia.Track.Type.Text -> player.getSpuTracks()
|
|
228
|
+
else -> null
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (tracks == null) return
|
|
232
|
+
|
|
233
|
+
val firstTrack = tracks.firstOrNull { track -> track.id != -1 }
|
|
234
|
+
val firstTrackId = firstTrack?.id
|
|
235
|
+
val index = trackId ?: firstTrackId
|
|
236
|
+
|
|
237
|
+
if (index == null) return
|
|
238
|
+
|
|
223
239
|
when (type) {
|
|
224
240
|
IMedia.Track.Type.Audio -> {
|
|
225
|
-
val firstTrack = player.getAudioTracks()?.firstOrNull { track -> track.id != -1 }?.id
|
|
226
|
-
val index = track ?: firstTrack ?: player.getAudioTrack()
|
|
227
241
|
player.setAudioTrack(index)
|
|
228
242
|
}
|
|
229
243
|
|
|
230
244
|
IMedia.Track.Type.Video -> {
|
|
231
|
-
val firstTrack = player.getVideoTracks()?.firstOrNull { track -> track.id != -1 }?.id
|
|
232
|
-
val index = track ?: firstTrack ?: player.getVideoTrack()
|
|
233
245
|
player.setVideoTrack(index)
|
|
234
246
|
}
|
|
235
247
|
|
|
236
248
|
IMedia.Track.Type.Text -> {
|
|
237
|
-
val firstTrack = player.getSpuTracks()?.firstOrNull { track -> track.id != -1 }?.id
|
|
238
|
-
val index = track ?: firstTrack ?: player.getSpuTrack()
|
|
239
249
|
player.setSpuTrack(index)
|
|
240
250
|
}
|
|
241
251
|
}
|
|
@@ -33,6 +33,18 @@ class PictureInPictureManager(
|
|
|
33
33
|
private var pipFragment: PictureInPictureFragment? = null
|
|
34
34
|
private var pipReceiver: BroadcastReceiver? = null
|
|
35
35
|
private var pipView: LibVlcPlayerView? = null
|
|
36
|
+
set(value) {
|
|
37
|
+
field = value
|
|
38
|
+
|
|
39
|
+
val canSetupPip = value != null && isPictureInPictureSupported()
|
|
40
|
+
|
|
41
|
+
if (canSetupPip) {
|
|
42
|
+
setupPipFragment()
|
|
43
|
+
setupPipReceiver()
|
|
44
|
+
setPipParams()
|
|
45
|
+
setPipActions()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
36
48
|
|
|
37
49
|
private val rootChildrenVisibility: MutableMap<Int, Int> = mutableMapOf()
|
|
38
50
|
|
|
@@ -47,13 +59,8 @@ class PictureInPictureManager(
|
|
|
47
59
|
private val pictureInPicture: Boolean
|
|
48
60
|
get() = pipView?.pictureInPicture == true
|
|
49
61
|
|
|
50
|
-
fun
|
|
51
|
-
if (!isPictureInPictureSupported()) return
|
|
62
|
+
fun setupPipView(view: LibVlcPlayerView) {
|
|
52
63
|
pipView = view
|
|
53
|
-
setupPipFragment()
|
|
54
|
-
setupPipReceiver()
|
|
55
|
-
setPipParams()
|
|
56
|
-
setPipActions()
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
private fun setupPipFragment() {
|
|
@@ -310,7 +317,7 @@ class PictureInPictureManager(
|
|
|
310
317
|
|
|
311
318
|
fun startPictureInPicture(view: LibVlcPlayerView) {
|
|
312
319
|
maybeThrowPipException()
|
|
313
|
-
|
|
320
|
+
setupPipView(view)
|
|
314
321
|
enterPictureInPicture()
|
|
315
322
|
}
|
|
316
323
|
|
|
@@ -115,9 +115,9 @@ class LibVlcPlayerView: ExpoView {
|
|
|
115
115
|
vlcDialog = nil
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
func selectTrack(_
|
|
118
|
+
func selectTrack(_ trackId: Int?, _ type: VLCMedia.TrackType) {
|
|
119
119
|
if let player = mediaPlayer {
|
|
120
|
-
if
|
|
120
|
+
if trackId == -1 {
|
|
121
121
|
switch type {
|
|
122
122
|
case .audio: player.deselectAllAudioTracks()
|
|
123
123
|
case .video: player.deselectAllVideoTracks()
|
|
@@ -136,9 +136,10 @@ class LibVlcPlayerView: ExpoView {
|
|
|
136
136
|
|
|
137
137
|
guard let tracks else { return }
|
|
138
138
|
|
|
139
|
-
let
|
|
140
|
-
let
|
|
141
|
-
let
|
|
139
|
+
let firstTrack = tracks.first?.trackId
|
|
140
|
+
let firstTrackInt = firstTrack.map { id in (id as NSString).intValue }
|
|
141
|
+
let firstTrackId = firstTrackInt.map { id in Int(id) }
|
|
142
|
+
let index = trackId ?? firstTrackId
|
|
142
143
|
|
|
143
144
|
guard let index else { return }
|
|
144
145
|
|
|
@@ -41,7 +41,7 @@ class PictureInPictureDrawable: MediaPlayerDrawable {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
func maybeThrowPipException() throws {
|
|
44
|
+
private func maybeThrowPipException() throws {
|
|
45
45
|
if !AVPictureInPictureController.isPictureInPictureSupported() {
|
|
46
46
|
throw PictureInPictureUnsupportedException()
|
|
47
47
|
} else if !pictureInPicture {
|