expo-libvlc-player 6.1.12 → 6.1.14
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.
|
@@ -290,50 +290,48 @@ class LibVlcPlayerView(
|
|
|
290
290
|
val view = getTextureView(layout) ?: return@post
|
|
291
291
|
val matrix = Matrix()
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
val video = getVideoSize()
|
|
293
|
+
val video = getVideoSize()
|
|
295
294
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
if (hasVideoSize) {
|
|
296
|
+
val viewWidth = view.width.toFloat()
|
|
297
|
+
val viewHeight = view.height.toFloat()
|
|
299
298
|
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
val videoWidth = video.width.toFloat()
|
|
300
|
+
val videoHeight = video.height.toFloat()
|
|
302
301
|
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
val viewAspect = viewWidth / viewHeight
|
|
303
|
+
val videoAspect = videoWidth / videoHeight
|
|
305
304
|
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
val pivotX = viewWidth / 2f
|
|
306
|
+
val pivotY = viewHeight / 2f
|
|
308
307
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
VideoContentFit.COVER -> {
|
|
315
|
-
val scale =
|
|
316
|
-
if (videoAspect > viewAspect) {
|
|
317
|
-
videoAspect / viewAspect
|
|
318
|
-
} else {
|
|
319
|
-
viewAspect / videoAspect
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
matrix.setScale(scale, scale, pivotX, pivotY)
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
VideoContentFit.FILL -> {
|
|
326
|
-
var scaleX = 1f
|
|
327
|
-
var scaleY = 1f
|
|
308
|
+
when (contentFit) {
|
|
309
|
+
VideoContentFit.CONTAIN -> {
|
|
310
|
+
// No scale required
|
|
311
|
+
}
|
|
328
312
|
|
|
313
|
+
VideoContentFit.COVER -> {
|
|
314
|
+
val scale =
|
|
329
315
|
if (videoAspect > viewAspect) {
|
|
330
|
-
|
|
316
|
+
videoAspect / viewAspect
|
|
331
317
|
} else {
|
|
332
|
-
|
|
318
|
+
viewAspect / videoAspect
|
|
333
319
|
}
|
|
334
320
|
|
|
335
|
-
|
|
321
|
+
matrix.setScale(scale, scale, pivotX, pivotY)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
VideoContentFit.FILL -> {
|
|
325
|
+
var scaleX = 1f
|
|
326
|
+
var scaleY = 1f
|
|
327
|
+
|
|
328
|
+
if (videoAspect > viewAspect) {
|
|
329
|
+
scaleY = videoAspect / viewAspect
|
|
330
|
+
} else {
|
|
331
|
+
scaleX = viewAspect / videoAspect
|
|
336
332
|
}
|
|
333
|
+
|
|
334
|
+
matrix.setScale(scaleX, scaleY, pivotX, pivotY)
|
|
337
335
|
}
|
|
338
336
|
}
|
|
339
337
|
}
|
|
@@ -417,12 +415,10 @@ class LibVlcPlayerView(
|
|
|
417
415
|
fun getMediaLength(): Long {
|
|
418
416
|
var length: Long = 0L
|
|
419
417
|
|
|
420
|
-
mediaPlayer?.
|
|
421
|
-
val duration = player.getLength()
|
|
418
|
+
val duration = mediaPlayer?.getLength() ?: 0L
|
|
422
419
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
420
|
+
if (duration > 0L) {
|
|
421
|
+
length = duration
|
|
426
422
|
}
|
|
427
423
|
|
|
428
424
|
return length
|
|
@@ -431,19 +427,17 @@ class LibVlcPlayerView(
|
|
|
431
427
|
fun getMediaInfo(): MediaInfo {
|
|
432
428
|
var mediaInfo = MediaInfo()
|
|
433
429
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
)
|
|
446
|
-
}
|
|
430
|
+
val video = getVideoSize()
|
|
431
|
+
val length = getMediaLength()
|
|
432
|
+
val seekable = mediaPlayer?.isSeekable() ?: false
|
|
433
|
+
|
|
434
|
+
mediaInfo =
|
|
435
|
+
MediaInfo(
|
|
436
|
+
width = video.width,
|
|
437
|
+
height = video.height,
|
|
438
|
+
length = length.toDouble(),
|
|
439
|
+
seekable = seekable,
|
|
440
|
+
)
|
|
447
441
|
|
|
448
442
|
return mediaInfo
|
|
449
443
|
}
|
|
@@ -655,24 +649,25 @@ class LibVlcPlayerView(
|
|
|
655
649
|
}
|
|
656
650
|
|
|
657
651
|
fun snapshot(path: String) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
val view = getTextureView(playerLayout) ?: throw Exception()
|
|
661
|
-
|
|
662
|
-
if (!hasVideoSize) throw Exception()
|
|
652
|
+
try {
|
|
653
|
+
val view = getTextureView(playerLayout) ?: throw Exception()
|
|
663
654
|
|
|
664
|
-
|
|
665
|
-
val video = getVideoSize()
|
|
666
|
-
val bitmap = Bitmap.createBitmap(video.width, video.height, Bitmap.Config.ARGB_8888)
|
|
655
|
+
if (!hasVideoSize) throw Exception()
|
|
667
656
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
657
|
+
val surface = Surface(view.surfaceTexture)
|
|
658
|
+
val video = getVideoSize()
|
|
659
|
+
val bitmap = Bitmap.createBitmap(video.width, video.height, Bitmap.Config.ARGB_8888)
|
|
660
|
+
|
|
661
|
+
PixelCopy.request(
|
|
662
|
+
surface,
|
|
663
|
+
bitmap,
|
|
664
|
+
{ copyResult ->
|
|
665
|
+
if (copyResult != PixelCopy.SUCCESS) {
|
|
666
|
+
onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
|
|
667
|
+
return@request
|
|
668
|
+
}
|
|
675
669
|
|
|
670
|
+
try {
|
|
676
671
|
val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd-HH'h'mm'm'ss's'")
|
|
677
672
|
val timestamp = simpleDateFormat.format(Calendar.getInstance().time)
|
|
678
673
|
|
|
@@ -684,12 +679,14 @@ class LibVlcPlayerView(
|
|
|
684
679
|
}
|
|
685
680
|
|
|
686
681
|
onSnapshotTaken(mapOf("path" to snapshotPath))
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
682
|
+
} catch (_: Exception) {
|
|
683
|
+
onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
Handler(Looper.getMainLooper()),
|
|
687
|
+
)
|
|
688
|
+
} catch (_: Exception) {
|
|
689
|
+
onEncounteredError(mapOf("error" to "Snapshot could not be taken"))
|
|
693
690
|
}
|
|
694
691
|
}
|
|
695
692
|
|
|
@@ -250,12 +250,10 @@ class LibVlcPlayerView: ExpoView {
|
|
|
250
250
|
func getMediaLength() -> Int32 {
|
|
251
251
|
var length: Int32 = 0
|
|
252
252
|
|
|
253
|
-
|
|
254
|
-
let duration = media.length.intValue
|
|
253
|
+
let duration = mediaPlayer?.media?.length.intValue ?? 0
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
255
|
+
if duration > 0 {
|
|
256
|
+
length = duration
|
|
259
257
|
}
|
|
260
258
|
|
|
261
259
|
return length
|
|
@@ -296,18 +294,16 @@ class LibVlcPlayerView: ExpoView {
|
|
|
296
294
|
func getMediaInfo() -> MediaInfo {
|
|
297
295
|
var mediaInfo = MediaInfo()
|
|
298
296
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
)
|
|
310
|
-
}
|
|
297
|
+
let video = getVideoSize()
|
|
298
|
+
let length = getMediaLength()
|
|
299
|
+
let seekable = mediaPlayer?.isSeekable ?? false
|
|
300
|
+
|
|
301
|
+
mediaInfo = MediaInfo(
|
|
302
|
+
width: Int(video.width),
|
|
303
|
+
height: Int(video.height),
|
|
304
|
+
length: Double(length),
|
|
305
|
+
seekable: seekable
|
|
306
|
+
)
|
|
311
307
|
|
|
312
308
|
return mediaInfo
|
|
313
309
|
}
|