@takeoffmedia/react-native-penthera 0.8.6 → 0.8.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.
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
4
4
  import android.content.Context
5
5
  import android.util.Log
6
6
  import com.bitmovin.player.api.media.subtitle.SubtitleTrack
7
- import com.bitmovin.player.reactnative.PlayerModule
7
+ import com.bitmovin.player.reactnative.PlayerRegistry
8
8
  import com.facebook.react.bridge.Arguments
9
9
  import com.facebook.react.bridge.Promise
10
10
  import com.facebook.react.bridge.ReactApplicationContext
@@ -135,16 +135,23 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
135
135
  for (i in 0 until subtitles.length()) {
136
136
  val subtitle = subtitles.getJSONObject(i)
137
137
  val language = subtitle["language"] as String
138
- val href = subtitle["href"]
139
- fileList.add(
140
- AncillaryFile(
141
- URL(href.toString()),
142
- language,
143
- arrayOf(language),
144
- language,
145
- URL(href.toString())
146
- )
147
- )
138
+ val href = subtitle.optString("href", "").trim()
139
+ if (href.isNotBlank() && !href.equals("null", ignoreCase = true)) {
140
+ try {
141
+ val subtitleUrl = URL(href)
142
+ fileList.add(
143
+ AncillaryFile(
144
+ subtitleUrl,
145
+ language,
146
+ arrayOf(language),
147
+ language,
148
+ subtitleUrl
149
+ )
150
+ )
151
+ } catch (e: MalformedURLException) {
152
+ Log.w("Penthera", "Skipping invalid subtitle URL: $href", e)
153
+ }
154
+ }
148
155
  }
149
156
 
150
157
  val params = MPDAssetBuilder().apply {
@@ -426,12 +433,11 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
426
433
  virtuoso.assetManager.getByAssetId(assetId)?.firstOrNull()?.let { asset ->
427
434
  val sourceManager = BitmovinSourceManager(context, asset as ISegmentedAsset)
428
435
  val sourceItem = sourceManager.bitmovinSourceItem
429
- val playerModule = context.getNativeModule(PlayerModule::class.java)
430
- if (playerModule != null && sourceItem != null) {
431
- var player = playerModule.getPlayerOrNull(nativeId)
436
+ if (sourceItem != null) {
437
+ var player = PlayerRegistry.getPlayer(nativeId)
432
438
  while (player == null) {
433
439
  Thread.sleep(100)
434
- player = playerModule.getPlayerOrNull(nativeId) as Nothing?
440
+ player = PlayerRegistry.getPlayer(nativeId)
435
441
  }
436
442
  val metadata = JSONObject(asset.metadata)
437
443
  val subtitles = JSONArray(metadata["subtitles"] as String)
@@ -487,7 +493,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
487
493
  }
488
494
 
489
495
  sourceItem.metadata = metaDataMap
490
- player.load(sourceItem)
496
+ player?.load(sourceItem)
491
497
  promise.resolve(true)
492
498
  }
493
499
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeoffmedia/react-native-penthera",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",