@takeoffmedia/react-native-penthera 0.4.2 → 0.4.3

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.
@@ -3,12 +3,13 @@ package com.takeoffmediareactnativepenthera.virtuoso
3
3
  import android.annotation.SuppressLint
4
4
  import android.content.Context
5
5
  import android.util.Log
6
+ import com.bitmovin.player.api.media.subtitle.SubtitleTrack
6
7
  import com.bitmovin.player.reactnative.PlayerModule
7
- import com.bitmovin.player.reactnative.converter.JsonConverter
8
8
  import com.facebook.react.bridge.Arguments
9
9
  import com.facebook.react.bridge.Promise
10
10
  import com.facebook.react.bridge.ReactApplicationContext
11
11
  import com.facebook.react.bridge.ReadableArray
12
+ import com.facebook.react.bridge.ReadableMap
12
13
  import com.facebook.react.bridge.UiThreadUtil
13
14
  import com.google.gson.Gson
14
15
  import com.penthera.virtuososdk.client.AncillaryFile
@@ -37,6 +38,7 @@ import com.penthera.virtuososdk.client.IService
37
38
  import com.takeoffmediareactnativepenthera.EventEmitter
38
39
  import com.takeoffmediareactnativepenthera.PentheraEvent
39
40
  import com.takeoffmediareactnativepenthera.virtuoso.errors.PentheraErrors
41
+ import java.util.UUID
40
42
 
41
43
  class OfflineVideoEngine(private val context: ReactApplicationContext) {
42
44
  private val virtuoso = Virtuoso(context)
@@ -328,6 +330,52 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
328
330
  return null
329
331
  }
330
332
 
333
+ private fun toSubtitleMimeType(format: String?): String? {
334
+ if (format == null) {
335
+ return null
336
+ }
337
+ return "text/${format}"
338
+ }
339
+
340
+ private fun toSubtitleTrack(json: ReadableMap?): SubtitleTrack? {
341
+ val url = json?.getString("url")
342
+ val label = json?.getString("label")
343
+ if (json == null || url == null || label == null) {
344
+ return null
345
+ }
346
+ val identifier = json.getString("identifier") ?: UUID.randomUUID().toString()
347
+ val isDefault = if (json.hasKey("isDefault")) {
348
+ json.getBoolean("isDefault")
349
+ } else {
350
+ false
351
+ }
352
+ val isForced = if (json.hasKey("isForced")) {
353
+ json.getBoolean("isForced")
354
+ } else {
355
+ false
356
+ }
357
+ val format = json.getString("format")
358
+ if (!format.isNullOrBlank()) {
359
+ return SubtitleTrack(
360
+ url = url,
361
+ label = label,
362
+ id = identifier,
363
+ isDefault = isDefault,
364
+ language = json.getString("language"),
365
+ isForced = isForced,
366
+ mimeType = toSubtitleMimeType(format),
367
+ )
368
+ }
369
+ return SubtitleTrack(
370
+ url = url,
371
+ label = label,
372
+ id = identifier,
373
+ isDefault = isDefault,
374
+ language = json.getString("language"),
375
+ isForced = isForced,
376
+ )
377
+ }
378
+
331
379
  fun loadBitmovinSourceManager(
332
380
  assetId: String,
333
381
  nativeId: String,
@@ -340,10 +388,10 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
340
388
  val sourceItem = sourceManager.bitmovinSourceItem
341
389
  val playerModule = context.getNativeModule(PlayerModule::class.java)
342
390
  if (playerModule != null && sourceItem != null) {
343
- var player = playerModule.getPlayer(nativeId)
391
+ var player = playerModule.getPlayerOrNull(nativeId)
344
392
  while (player == null) {
345
393
  Thread.sleep(100)
346
- player = playerModule.getPlayer(nativeId) as Nothing?
394
+ player = playerModule.getPlayerOrNull(nativeId) as Nothing?
347
395
  }
348
396
  val metadata = JSONObject(asset.metadata)
349
397
  val subtitles = JSONArray(metadata["subtitles"] as String)
@@ -362,7 +410,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
362
410
  subtitleMap.putString("label", subtitle.getString("label"))
363
411
  subtitleMap.putString("format", "vtt")
364
412
 
365
- JsonConverter.toSubtitleTrack(subtitleMap)?.let {
413
+ toSubtitleTrack(subtitleMap)?.let {
366
414
  sourceItem.addSubtitleTrack(it)
367
415
  }
368
416
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeoffmedia/react-native-penthera",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>
@@ -1,104 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Bucket
3
- uuid = "3AE98629-7421-4561-B12C-C06B8B6A3023"
4
- type = "1"
5
- version = "2.0">
6
- <Breakpoints>
7
- <BreakpointProxy
8
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9
- <BreakpointContent
10
- uuid = "A5D166B0-3C57-4F4D-A845-BDB81498DA0F"
11
- shouldBeEnabled = "No"
12
- ignoreCount = "0"
13
- continueAfterRunningActions = "No"
14
- filePath = "Penthera.swift"
15
- startingColumnNumber = "9223372036854775807"
16
- endingColumnNumber = "9223372036854775807"
17
- startingLineNumber = "18"
18
- endingLineNumber = "18"
19
- landmarkName = "Penthera"
20
- landmarkType = "3">
21
- </BreakpointContent>
22
- </BreakpointProxy>
23
- <BreakpointProxy
24
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
25
- <BreakpointContent
26
- uuid = "5D7AE47B-D5FC-4468-A75B-C414F3F8A58C"
27
- shouldBeEnabled = "No"
28
- ignoreCount = "0"
29
- continueAfterRunningActions = "No"
30
- filePath = "Penthera.swift"
31
- startingColumnNumber = "9223372036854775807"
32
- endingColumnNumber = "9223372036854775807"
33
- startingLineNumber = "25"
34
- endingLineNumber = "25"
35
- landmarkName = "updateStatusInfo()"
36
- landmarkType = "7">
37
- </BreakpointContent>
38
- </BreakpointProxy>
39
- <BreakpointProxy
40
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
41
- <BreakpointContent
42
- uuid = "E3C50B30-46CF-4D56-8C49-C257C70E0ACC"
43
- shouldBeEnabled = "No"
44
- ignoreCount = "0"
45
- continueAfterRunningActions = "No"
46
- filePath = "Penthera.swift"
47
- startingColumnNumber = "9223372036854775807"
48
- endingColumnNumber = "9223372036854775807"
49
- startingLineNumber = "26"
50
- endingLineNumber = "26"
51
- landmarkName = "updateStatusInfo()"
52
- landmarkType = "7">
53
- </BreakpointContent>
54
- </BreakpointProxy>
55
- <BreakpointProxy
56
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
57
- <BreakpointContent
58
- uuid = "75EF43BF-56FF-4727-B372-E1A0EBC02C61"
59
- shouldBeEnabled = "Yes"
60
- ignoreCount = "0"
61
- continueAfterRunningActions = "No"
62
- filePath = "Penthera.swift"
63
- startingColumnNumber = "9223372036854775807"
64
- endingColumnNumber = "9223372036854775807"
65
- startingLineNumber = "101"
66
- endingLineNumber = "101"
67
- landmarkName = "initializeSdk(user:backplaneUrl:publicKey:privateKey:resolve:reject:)"
68
- landmarkType = "7">
69
- </BreakpointContent>
70
- </BreakpointProxy>
71
- <BreakpointProxy
72
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
73
- <BreakpointContent
74
- uuid = "EF36B51B-4FC2-4989-A791-180E3212EFE3"
75
- shouldBeEnabled = "Yes"
76
- ignoreCount = "0"
77
- continueAfterRunningActions = "No"
78
- filePath = "Penthera.swift"
79
- startingColumnNumber = "9223372036854775807"
80
- endingColumnNumber = "9223372036854775807"
81
- startingLineNumber = "149"
82
- endingLineNumber = "149"
83
- landmarkName = "getDownloadedAsset(assetID:)"
84
- landmarkType = "7">
85
- </BreakpointContent>
86
- </BreakpointProxy>
87
- <BreakpointProxy
88
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
89
- <BreakpointContent
90
- uuid = "C467C00E-2428-4D24-843A-E7CDF28CB553"
91
- shouldBeEnabled = "Yes"
92
- ignoreCount = "0"
93
- continueAfterRunningActions = "No"
94
- filePath = "Penthera.swift"
95
- startingColumnNumber = "9223372036854775807"
96
- endingColumnNumber = "9223372036854775807"
97
- startingLineNumber = "148"
98
- endingLineNumber = "148"
99
- landmarkName = "getDownloadedAsset(assetID:)"
100
- landmarkType = "7">
101
- </BreakpointContent>
102
- </BreakpointProxy>
103
- </Breakpoints>
104
- </Bucket>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>Penthera.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>