expo-libmpv 0.5.11 → 0.5.13

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.
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'com.libmpv'
4
- version = '0.5.0'
4
+ version = '0.5.13'
5
5
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
6
6
  apply from: expoModulesCorePlugin
7
7
  applyKotlinExpoModulesCorePlugin()
@@ -43,7 +43,7 @@ android {
43
43
  namespace "com.libmpv"
44
44
  defaultConfig {
45
45
  versionCode 1
46
- versionName "0.5.0"
46
+ versionName "0.5.13"
47
47
  }
48
48
  lintOptions {
49
49
  abortOnError false
@@ -8,6 +8,10 @@ import com.libmpv.LibmpvSession
8
8
  import dev.jdtech.mpv.MPVLib
9
9
  import java.io.File
10
10
  import java.io.FileOutputStream
11
+ import org.json.JSONArray
12
+ import org.json.JSONObject
13
+ import java.util.ArrayList
14
+ import java.util.HashMap
11
15
 
12
16
  class LibmpvRenderer(
13
17
  private val session: LibmpvSession,
@@ -252,22 +256,23 @@ class LibmpvRenderer(
252
256
  if (!videoSync.isNullOrBlank()) {
253
257
  if (videoSync == "display-resample") {
254
258
  MPVLib.setOptionString("video-sync", "display-resample")
255
- MPVLib.setOptionString("audio-pitch-correction", "no")
256
- MPVLib.setOptionString("autosync", "1")
257
- MPVLib.setOptionString("correct-pts", "no")
259
+ MPVLib.setOptionString("interpolation", "yes")
260
+ MPVLib.setOptionString("tscale", "oversample")
261
+ MPVLib.setOptionString("audio-pitch-correction", "yes")
258
262
  }
259
263
  if (videoSync == "audio") {
260
264
  MPVLib.setOptionString("video-sync", "audio")
261
- MPVLib.setOptionString("audio-pitch-correction", "yes")
262
- MPVLib.setOptionString("autosync", "0")
263
- MPVLib.setOptionString("correct-pts", "yes")
265
+ MPVLib.setOptionString("interpolation", "no")
266
+ MPVLib.setOptionString("tscale", "off")
264
267
  }
268
+ } else {
269
+ MPVLib.setOptionString("video-sync", "audio")
270
+ MPVLib.setOptionString("interpolation", "no")
271
+ MPVLib.setOptionString("tscale", "off")
265
272
  }
266
273
 
267
274
  MPVLib.setOptionString("scale", "bilinear")
268
275
  MPVLib.setOptionString("dscale", "bilinear")
269
- MPVLib.setOptionString("tscale", "off")
270
- MPVLib.setOptionString("interpolation", "no")
271
276
 
272
277
  MPVLib.setOptionString("alang", "")
273
278
  MPVLib.setOptionString("ao", "audiotrack")
@@ -392,13 +397,14 @@ class LibmpvRenderer(
392
397
  }
393
398
 
394
399
  override fun logMessage(prefix: String, level: Int, text: String) {
395
- if (shuttingDown) {
396
- return
397
- }
400
+ if (shuttingDown) return
401
+
402
+ val safeText = if (text.length > 1000) text.substring(0, 1000) + "..." else text
403
+
398
404
  if (level <= LOG_LEVEL_WARN) {
399
- Log.w(TAG, "[$prefix] $text")
405
+ Log.w(TAG, "[$prefix] $safeText")
400
406
  }
401
- onLog(mapOf("prefix" to prefix, "level" to level, "text" to text))
407
+ onLog(mapOf("prefix" to prefix, "level" to level, "text" to safeText))
402
408
  }
403
409
 
404
410
  override fun event(eventId: Int) {
@@ -435,7 +441,42 @@ class LibmpvRenderer(
435
441
  }
436
442
 
437
443
  override fun eventProperty(property: String, value: String) {
438
- onEvent(mapOf("property" to property, "kind" to "string", "value" to value))
444
+ if (property == "track-list") {
445
+ try {
446
+ val jsonArray = JSONArray(value)
447
+ val tracks = ArrayList<Map<String, Any>>()
448
+
449
+ for (i in 0 until jsonArray.length()) {
450
+ val item = jsonArray.getJSONObject(i)
451
+ val map = HashMap<String, Any>()
452
+ val keys = item.keys()
453
+
454
+ while (keys.hasNext()) {
455
+ val key = keys.next()
456
+ map[key] = item.opt(key).toString()
457
+ }
458
+ tracks.add(map)
459
+ }
460
+
461
+ onEvent(mapOf(
462
+ "property" to property,
463
+ "kind" to "track-list",
464
+ "value" to tracks
465
+ ))
466
+ return
467
+ } catch (e: Exception) {
468
+ Log.e(TAG, "Failed to parse track-list JSON", e)
469
+ }
470
+ }
471
+
472
+ val safeValue = if (value.length > 1000) {
473
+ Log.w(TAG, "Truncating massive property: $property")
474
+ value.substring(0, 1000) + "..."
475
+ } else {
476
+ value
477
+ }
478
+
479
+ onEvent(mapOf("property" to property, "kind" to "string", "value" to safeValue))
439
480
  }
440
481
 
441
482
  private fun createMpvDirectory() {
@@ -48,23 +48,23 @@ class LibmpvView(
48
48
  return attached && surfaceReady
49
49
  }
50
50
 
51
- private fun reconcileRenderer() {
52
- if (renderer == null && attached) {
53
- renderer = LibmpvRenderer(
54
- session = session,
55
- surfaceView = surfaceView,
56
- onLog = { payload -> onLibmpvLog(payload) },
57
- onEvent = { payload -> onLibmpvEvent(payload) }
58
- )
59
- renderer!!.start()
60
- }
51
+ private fun reconcileRenderer() {
52
+ if (renderer == null && attached) {
53
+ renderer = LibmpvRenderer(
54
+ session = session,
55
+ surfaceView = surfaceView,
56
+ onLog = { payload -> onLibmpvLog(payload) },
57
+ onEvent = { payload -> onLibmpvEvent(payload) }
58
+ )
59
+ renderer!!.start()
60
+ }
61
61
 
62
- renderer?.let { r ->
63
- if (surfaceReady) {
64
- r.attachSurfaceIfNeeded()
62
+ renderer?.let { r ->
63
+ if (surfaceReady) {
64
+ r.attachSurfaceIfNeeded()
65
+ }
65
66
  }
66
67
  }
67
- }
68
68
 
69
69
 
70
70
  fun onSessionUpdatedFromProps() {
package/app.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "expo": {
3
- "runtimeVersion": "0.5.0",
3
+ "runtimeVersion": "0.5.13",
4
4
  "plugins": [
5
5
  [
6
6
  "expo-build-properties",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-libmpv",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "A libmpv Fabric component for Android",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",