expo-libvlc-player 3.4.3 → 3.4.5
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/build.gradle +2 -2
- package/android/src/main/java/expo/modules/libvlcplayer/LibVlcPlayerView.kt +48 -43
- package/android/src/main/java/expo/modules/libvlcplayer/MediaPlayerListener.kt +1 -1
- package/ios/LibVlcPlayerView.swift +42 -39
- package/ios/MediaPlayerDelegate.swift +1 -1
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: "com.android.library"
|
|
2
2
|
|
|
3
3
|
group = "expo.modules.libvlcplayer"
|
|
4
|
-
version = "3.4.
|
|
4
|
+
version = "3.4.5"
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -27,7 +27,7 @@ android {
|
|
|
27
27
|
namespace "expo.modules.libvlcplayer"
|
|
28
28
|
defaultConfig {
|
|
29
29
|
versionCode 1
|
|
30
|
-
versionName "3.4.
|
|
30
|
+
versionName "3.4.5"
|
|
31
31
|
consumerProguardFiles("proguard-rules.pro")
|
|
32
32
|
}
|
|
33
33
|
lintOptions {
|
|
@@ -60,7 +60,7 @@ class LibVlcPlayerView(
|
|
|
60
60
|
private var media: Media? = null
|
|
61
61
|
var vlcDialog: VLCDialog? = null
|
|
62
62
|
|
|
63
|
-
var mediaLength: Long =
|
|
63
|
+
var mediaLength: Long? = null
|
|
64
64
|
|
|
65
65
|
private var shouldCreate: Boolean = false
|
|
66
66
|
var firstPlay: Boolean = false
|
|
@@ -203,58 +203,60 @@ class LibVlcPlayerView(
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
fun setContentFit() {
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
post {
|
|
207
|
+
mediaPlayer?.let { player ->
|
|
208
|
+
val textureView = getTextureView() ?: return@post
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
val video = player.getCurrentVideoTrack()
|
|
210
211
|
|
|
211
|
-
|
|
212
|
+
val matrix = Matrix()
|
|
212
213
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
if (video != null) {
|
|
215
|
+
val viewWidth = playerView.width.toFloat()
|
|
216
|
+
val viewHeight = playerView.height.toFloat()
|
|
216
217
|
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
val videoWidth = video.width.toFloat()
|
|
219
|
+
val videoHeight = video.height.toFloat()
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
val viewAspect = viewWidth / viewHeight
|
|
222
|
+
val videoAspect = videoWidth / videoHeight
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
val pivotX = viewWidth / 2f
|
|
225
|
+
val pivotY = viewHeight / 2f
|
|
225
226
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
when (contentFit) {
|
|
228
|
+
VideoContentFit.CONTAIN -> {
|
|
229
|
+
// No scale required
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
VideoContentFit.COVER -> {
|
|
233
|
+
val scale =
|
|
234
|
+
if (videoAspect > viewAspect) {
|
|
235
|
+
videoAspect / viewAspect
|
|
236
|
+
} else {
|
|
237
|
+
viewAspect / videoAspect
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
matrix.setScale(scale, scale, pivotX, pivotY)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
VideoContentFit.FILL -> {
|
|
244
|
+
var scaleX = 1f
|
|
245
|
+
var scaleY = 1f
|
|
230
246
|
|
|
231
|
-
VideoContentFit.COVER -> {
|
|
232
|
-
val scale =
|
|
233
247
|
if (videoAspect > viewAspect) {
|
|
234
|
-
videoAspect / viewAspect
|
|
248
|
+
scaleY = videoAspect / viewAspect
|
|
235
249
|
} else {
|
|
236
|
-
viewAspect / videoAspect
|
|
250
|
+
scaleX = viewAspect / videoAspect
|
|
237
251
|
}
|
|
238
252
|
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
VideoContentFit.FILL -> {
|
|
243
|
-
var scaleX = 1f
|
|
244
|
-
var scaleY = 1f
|
|
245
|
-
|
|
246
|
-
if (videoAspect > viewAspect) {
|
|
247
|
-
scaleY = videoAspect / viewAspect
|
|
248
|
-
} else {
|
|
249
|
-
scaleX = viewAspect / videoAspect
|
|
253
|
+
matrix.setScale(scaleX, scaleY, pivotX, pivotY)
|
|
250
254
|
}
|
|
251
|
-
|
|
252
|
-
matrix.setScale(scaleX, scaleY, pivotX, pivotY)
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
|
-
}
|
|
256
257
|
|
|
257
|
-
|
|
258
|
+
textureView.setTransform(matrix)
|
|
259
|
+
}
|
|
258
260
|
}
|
|
259
261
|
}
|
|
260
262
|
|
|
@@ -321,7 +323,12 @@ class LibVlcPlayerView(
|
|
|
321
323
|
tracks = mediaTracks,
|
|
322
324
|
)
|
|
323
325
|
|
|
324
|
-
mediaLength =
|
|
326
|
+
mediaLength =
|
|
327
|
+
if (length > 0L) {
|
|
328
|
+
length
|
|
329
|
+
} else {
|
|
330
|
+
null
|
|
331
|
+
}
|
|
325
332
|
}
|
|
326
333
|
|
|
327
334
|
return mediaInfo
|
|
@@ -398,10 +405,7 @@ class LibVlcPlayerView(
|
|
|
398
405
|
var aspectRatio: String? = null
|
|
399
406
|
set(value) {
|
|
400
407
|
field = value
|
|
401
|
-
|
|
402
|
-
post {
|
|
403
|
-
setContentFit()
|
|
404
|
-
}
|
|
408
|
+
setContentFit()
|
|
405
409
|
}
|
|
406
410
|
|
|
407
411
|
var contentFit: VideoContentFit = VideoContentFit.CONTAIN
|
|
@@ -515,7 +519,8 @@ class LibVlcPlayerView(
|
|
|
515
519
|
}
|
|
516
520
|
} else {
|
|
517
521
|
if (type == "position") {
|
|
518
|
-
|
|
522
|
+
val length = mediaLength ?: 0L
|
|
523
|
+
time = (value * length.toDouble()).toInt()
|
|
519
524
|
} else {
|
|
520
525
|
time = value.toInt()
|
|
521
526
|
}
|
|
@@ -23,7 +23,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
23
23
|
var vlcDialog: VLCDialogProvider?
|
|
24
24
|
var vlcDialogRef: NSValue?
|
|
25
25
|
|
|
26
|
-
var mediaLength: Int32
|
|
26
|
+
var mediaLength: Int32?
|
|
27
27
|
private var oldVolume: Int = maxPlayerVolume
|
|
28
28
|
|
|
29
29
|
private var shouldCreate: Bool = false
|
|
@@ -143,42 +143,44 @@ class LibVlcPlayerView: ExpoView {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
func setContentFit() {
|
|
146
|
-
|
|
147
|
-
let
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
videoAspect
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
146
|
+
DispatchQueue.main.async {
|
|
147
|
+
if let player = self.mediaPlayer {
|
|
148
|
+
let view = self.playerView.frame.size
|
|
149
|
+
|
|
150
|
+
let video = player.videoSize
|
|
151
|
+
|
|
152
|
+
var transform: CGAffineTransform = .identity
|
|
153
|
+
|
|
154
|
+
if video != .zero {
|
|
155
|
+
let viewAspect = view.width / view.height
|
|
156
|
+
let videoAspect = video.width / video.height
|
|
157
|
+
|
|
158
|
+
switch self.contentFit {
|
|
159
|
+
case .contain:
|
|
160
|
+
// No transform required
|
|
161
|
+
break
|
|
162
|
+
case .cover:
|
|
163
|
+
let scale = videoAspect > viewAspect ?
|
|
164
|
+
videoAspect / viewAspect :
|
|
165
|
+
viewAspect / videoAspect
|
|
166
|
+
|
|
167
|
+
transform = CGAffineTransform(scaleX: scale, y: scale)
|
|
168
|
+
case .fill:
|
|
169
|
+
var scaleX = 1.0
|
|
170
|
+
var scaleY = 1.0
|
|
171
|
+
|
|
172
|
+
if videoAspect > viewAspect {
|
|
173
|
+
scaleY = videoAspect / viewAspect
|
|
174
|
+
} else {
|
|
175
|
+
scaleX = viewAspect / videoAspect
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
transform = CGAffineTransform(scaleX: scaleX, y: scaleY)
|
|
175
179
|
}
|
|
176
|
-
|
|
177
|
-
transform = CGAffineTransform(scaleX: scaleX, y: scaleY)
|
|
178
180
|
}
|
|
179
|
-
}
|
|
180
181
|
|
|
181
|
-
|
|
182
|
+
self.playerView.transform = transform
|
|
183
|
+
}
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
|
|
@@ -246,7 +248,9 @@ class LibVlcPlayerView: ExpoView {
|
|
|
246
248
|
tracks: mediaTracks,
|
|
247
249
|
)
|
|
248
250
|
|
|
249
|
-
mediaLength = length
|
|
251
|
+
mediaLength = length > 0 ?
|
|
252
|
+
length :
|
|
253
|
+
nil
|
|
250
254
|
}
|
|
251
255
|
|
|
252
256
|
return mediaInfo
|
|
@@ -325,9 +329,7 @@ class LibVlcPlayerView: ExpoView {
|
|
|
325
329
|
|
|
326
330
|
var aspectRatio: String? {
|
|
327
331
|
didSet {
|
|
328
|
-
|
|
329
|
-
self.setContentFit()
|
|
330
|
-
}
|
|
332
|
+
setContentFit()
|
|
331
333
|
}
|
|
332
334
|
}
|
|
333
335
|
|
|
@@ -428,7 +430,8 @@ class LibVlcPlayerView: ExpoView {
|
|
|
428
430
|
}
|
|
429
431
|
} else {
|
|
430
432
|
if type == "position" {
|
|
431
|
-
|
|
433
|
+
let length = mediaLength ?? 0
|
|
434
|
+
time = Int(value * Double(length))
|
|
432
435
|
} else {
|
|
433
436
|
time = Int(value)
|
|
434
437
|
}
|