expo-libmpv 0.5.5 → 0.5.7
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.
|
@@ -284,10 +284,7 @@ class LibmpvRenderer(
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
private fun maybeStartPlayback() {
|
|
287
|
-
if (state != State.ACTIVE) {
|
|
288
|
-
return
|
|
289
|
-
}
|
|
290
|
-
if (!surfaceAttached) {
|
|
287
|
+
if (state != State.ACTIVE || !surfaceAttached) {
|
|
291
288
|
return
|
|
292
289
|
}
|
|
293
290
|
|
|
@@ -298,13 +295,27 @@ class LibmpvRenderer(
|
|
|
298
295
|
|
|
299
296
|
try {
|
|
300
297
|
loadedUrl = url
|
|
301
|
-
MPVLib.
|
|
302
|
-
|
|
298
|
+
MPVLib.setOptionString("start", "0")
|
|
299
|
+
|
|
300
|
+
val start = session.seekToSeconds
|
|
301
|
+
if (start != null) {
|
|
302
|
+
MPVLib.setOptionString("start", start.toLong().toString())
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
MPVLib.command(
|
|
306
|
+
arrayOf(
|
|
307
|
+
"loadfile",
|
|
308
|
+
url,
|
|
309
|
+
"replace"
|
|
310
|
+
)
|
|
311
|
+
)
|
|
312
|
+
|
|
303
313
|
} catch (e: Exception) {
|
|
304
314
|
logException(e)
|
|
305
315
|
}
|
|
306
316
|
}
|
|
307
317
|
|
|
318
|
+
|
|
308
319
|
private fun applyContinuousState() {
|
|
309
320
|
if (!mpvAlive || shuttingDown) {
|
|
310
321
|
return
|
|
@@ -319,22 +330,10 @@ class LibmpvRenderer(
|
|
|
319
330
|
}
|
|
320
331
|
|
|
321
332
|
private fun applyDeferredState() {
|
|
322
|
-
if (!
|
|
333
|
+
if (!session.hasFileLoaded || !surfaceAttached || state != State.ACTIVE) {
|
|
323
334
|
return
|
|
324
335
|
}
|
|
325
336
|
|
|
326
|
-
session.seekToSeconds?.let { target ->
|
|
327
|
-
if (session.needsApply(LibmpvSession.MpvIntent.SEEK)) {
|
|
328
|
-
val timePos = MPVLib.getPropertyDouble("time-pos")
|
|
329
|
-
val seekable = MPVLib.getPropertyBoolean("seekable") == true
|
|
330
|
-
|
|
331
|
-
if (seekable && timePos != null && kotlin.math.abs(timePos - target) > 0.5) {
|
|
332
|
-
MPVLib.command(arrayOf("seek", target.toString(), "absolute"))
|
|
333
|
-
session.markApplied(LibmpvSession.MpvIntent.SEEK)
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
337
|
session.selectedAudioTrack?.let {
|
|
339
338
|
if (session.needsApply(LibmpvSession.MpvIntent.AUDIO_TRACK)) {
|
|
340
339
|
val aid = if (it == -1) "no" else (it + 1).toString()
|
|
@@ -354,6 +353,20 @@ class LibmpvRenderer(
|
|
|
354
353
|
session.markApplied(LibmpvSession.MpvIntent.SUBTITLE_TRACK)
|
|
355
354
|
}
|
|
356
355
|
}
|
|
356
|
+
|
|
357
|
+
if (session.needsApply(LibmpvSession.MpvIntent.SEEK)) {
|
|
358
|
+
val target = session.seekToSeconds
|
|
359
|
+
if (target != null) {
|
|
360
|
+
MPVLib.command(
|
|
361
|
+
arrayOf(
|
|
362
|
+
"seek",
|
|
363
|
+
target.toString(),
|
|
364
|
+
"absolute"
|
|
365
|
+
)
|
|
366
|
+
)
|
|
367
|
+
session.markApplied(LibmpvSession.MpvIntent.SEEK)
|
|
368
|
+
}
|
|
369
|
+
}
|
|
357
370
|
}
|
|
358
371
|
|
|
359
372
|
private fun stopPlayback() {
|
|
@@ -382,7 +395,10 @@ class LibmpvRenderer(
|
|
|
382
395
|
|
|
383
396
|
override fun event(eventId: Int) {
|
|
384
397
|
when (eventId) {
|
|
385
|
-
MPVLib.MpvEvent.MPV_EVENT_FILE_LOADED
|
|
398
|
+
MPVLib.MpvEvent.MPV_EVENT_FILE_LOADED -> {
|
|
399
|
+
session.hasFileLoaded = true
|
|
400
|
+
}
|
|
401
|
+
|
|
386
402
|
MPVLib.MpvEvent.MPV_EVENT_PLAYBACK_RESTART -> {
|
|
387
403
|
session.hasFileLoaded = true
|
|
388
404
|
applyDeferredState()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-libmpv",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "A libmpv Fabric component for Android",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"homepage": "https://github.com/XBigTK13X/expo-libmpv#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"expo-build-properties": "1.0.
|
|
31
|
+
"expo-build-properties": "1.0.10"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/react": "~19.1.10",
|
|
35
|
-
"expo": "54.0.
|
|
35
|
+
"expo": "54.0.29",
|
|
36
36
|
"expo-module-scripts": "^4.1.10",
|
|
37
37
|
"react": "19.1.0",
|
|
38
38
|
"react-native": "0.81.5"
|