expo-libmpv 0.5.9 → 0.5.11

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.
@@ -34,10 +34,11 @@ class LibmpvRenderer(
34
34
  private val stateLock = Any()
35
35
 
36
36
  @Volatile private var state: State = State.NEW
37
- @Volatile private var destroyed = false
38
- @Volatile private var loadedUrl: String? = null
39
37
  @Volatile private var surfaceAttached = false
40
38
  @Volatile var surfaceReady = false
39
+ @Volatile private var loadedUrl: String? = null
40
+ @Volatile private var playbackStarted = false
41
+ @Volatile private var destroyed = false
41
42
 
42
43
  private var mpvDirectory: String? = null
43
44
 
@@ -295,6 +296,17 @@ class LibmpvRenderer(
295
296
 
296
297
  try {
297
298
  loadedUrl = url
299
+
300
+ playbackStarted = false
301
+
302
+ val initialSeek = session.seekToSeconds
303
+ if (initialSeek != null && session.needsApply(LibmpvSession.MpvIntent.SEEK)) {
304
+ MPVLib.setOptionString("start", initialSeek.toString())
305
+ session.markApplied(LibmpvSession.MpvIntent.SEEK)
306
+ } else {
307
+ MPVLib.setOptionString("start", "0")
308
+ }
309
+
298
310
  MPVLib.command(
299
311
  arrayOf(
300
312
  "loadfile",
@@ -391,8 +403,12 @@ class LibmpvRenderer(
391
403
 
392
404
  override fun event(eventId: Int) {
393
405
  when (eventId) {
394
- MPVLib.MpvEvent.MPV_EVENT_FILE_LOADED,
406
+ MPVLib.MpvEvent.MPV_EVENT_FILE_LOADED -> {
407
+ session.hasFileLoaded = true
408
+ applyDeferredState()
409
+ }
395
410
  MPVLib.MpvEvent.MPV_EVENT_PLAYBACK_RESTART -> {
411
+ playbackStarted = true
396
412
  session.hasFileLoaded = true
397
413
  applyDeferredState()
398
414
  }
@@ -412,6 +428,9 @@ class LibmpvRenderer(
412
428
  }
413
429
 
414
430
  override fun eventProperty(property: String, value: Boolean) {
431
+ if (property == "eof-reached" && !playbackStarted) {
432
+ return
433
+ }
415
434
  onEvent(mapOf("property" to property, "kind" to "boolean", "value" to value))
416
435
  }
417
436
 
@@ -518,4 +537,4 @@ class LibmpvRenderer(
518
537
  Log.e(TAG, "mpv error", e)
519
538
  }
520
539
  }
521
- }
540
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libmpv",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "description": "A libmpv Fabric component for Android",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",