expo-libmpv 0.5.6 → 0.5.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.
@@ -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,12 +295,27 @@ class LibmpvRenderer(
298
295
 
299
296
  try {
300
297
  loadedUrl = url
301
- MPVLib.command(arrayOf("loadfile", url, "replace"))
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
+
302
313
  } catch (e: Exception) {
303
314
  logException(e)
304
315
  }
305
316
  }
306
317
 
318
+
307
319
  private fun applyContinuousState() {
308
320
  if (!mpvAlive || shuttingDown) {
309
321
  return
@@ -322,20 +334,6 @@ class LibmpvRenderer(
322
334
  return
323
335
  }
324
336
 
325
- session.seekToSeconds?.let { target ->
326
- if (session.needsApply(LibmpvSession.MpvIntent.SEEK)) {
327
- val seekable = MPVLib.getPropertyBoolean("seekable") == true
328
-
329
- if (seekable && surfaceAttached && state == State.ACTIVE) {
330
- MPVLib.command(arrayOf("set", "pause", "yes"))
331
- MPVLib.command(arrayOf("seek", target.toString(), "absolute"))
332
- MPVLib.command(arrayOf("set", "pause", if (session.isPlaying) "no" else "yes"))
333
- session.markApplied(LibmpvSession.MpvIntent.SEEK)
334
- }
335
- }
336
- }
337
-
338
-
339
337
  session.selectedAudioTrack?.let {
340
338
  if (session.needsApply(LibmpvSession.MpvIntent.AUDIO_TRACK)) {
341
339
  val aid = if (it == -1) "no" else (it + 1).toString()
@@ -355,6 +353,24 @@ class LibmpvRenderer(
355
353
  session.markApplied(LibmpvSession.MpvIntent.SUBTITLE_TRACK)
356
354
  }
357
355
  }
356
+
357
+ if (session.needsApply(LibmpvSession.MpvIntent.SEEK)) {
358
+ val target = session.seekToSeconds
359
+ if (target != null) {
360
+ if (!session.hasFileLoaded) {
361
+ return
362
+ }
363
+ MPVLib.command(
364
+ arrayOf(
365
+ "seek",
366
+ target.toString(),
367
+ "absolute"
368
+ )
369
+ )
370
+ session.markApplied(LibmpvSession.MpvIntent.SEEK)
371
+ }
372
+ }
373
+
358
374
  }
359
375
 
360
376
  private fun stopPlayback() {
@@ -383,10 +399,7 @@ class LibmpvRenderer(
383
399
 
384
400
  override fun event(eventId: Int) {
385
401
  when (eventId) {
386
- MPVLib.MpvEvent.MPV_EVENT_FILE_LOADED -> {
387
- session.hasFileLoaded = true
388
- }
389
-
402
+ MPVLib.MpvEvent.MPV_EVENT_FILE_LOADED,
390
403
  MPVLib.MpvEvent.MPV_EVENT_PLAYBACK_RESTART -> {
391
404
  session.hasFileLoaded = true
392
405
  applyDeferredState()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libmpv",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "A libmpv Fabric component for Android",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",