@takeoffmedia/react-native-penthera 0.5.4 → 0.5.6
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.
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt
CHANGED
|
@@ -12,6 +12,7 @@ import com.facebook.react.bridge.ReadableArray
|
|
|
12
12
|
import com.facebook.react.bridge.ReadableMap
|
|
13
13
|
import com.facebook.react.bridge.UiThreadUtil
|
|
14
14
|
import com.google.gson.Gson
|
|
15
|
+
import com.penthera.common.Common
|
|
15
16
|
import com.penthera.virtuososdk.client.AncillaryFile
|
|
16
17
|
import com.penthera.virtuososdk.client.EngineObserver
|
|
17
18
|
import com.penthera.virtuososdk.client.IAsset
|
|
@@ -19,23 +20,22 @@ import com.penthera.virtuososdk.client.IIdentifier
|
|
|
19
20
|
import com.penthera.virtuososdk.client.IPushRegistrationObserver
|
|
20
21
|
import com.penthera.virtuososdk.client.ISegmentedAsset
|
|
21
22
|
import com.penthera.virtuososdk.client.ISegmentedAssetFromParserObserver
|
|
23
|
+
import com.penthera.virtuososdk.client.IService
|
|
22
24
|
import com.penthera.virtuososdk.client.Virtuoso
|
|
23
25
|
import com.penthera.virtuososdk.client.bitmovin.BitmovinSourceManager
|
|
24
26
|
import com.penthera.virtuososdk.client.builders.MPDAssetBuilder
|
|
25
27
|
import com.penthera.virtuososdk.interfaces.toolkit.VirtuosoSegmentedFile
|
|
26
28
|
import com.takeoffmediareactnativepenthera.AssetQueueObserver
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
+
import com.takeoffmediareactnativepenthera.EventEmitter
|
|
30
|
+
import com.takeoffmediareactnativepenthera.PentheraEvent
|
|
31
|
+
import com.takeoffmediareactnativepenthera.virtuoso.errors.PentheraErrors
|
|
29
32
|
import org.json.JSONArray
|
|
30
33
|
import org.json.JSONObject
|
|
31
|
-
import java.
|
|
34
|
+
import java.net.HttpURLConnection
|
|
32
35
|
import java.net.MalformedURLException
|
|
33
36
|
import java.net.URL
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import com.takeoffmediareactnativepenthera.EventEmitter
|
|
37
|
-
import com.takeoffmediareactnativepenthera.PentheraEvent
|
|
38
|
-
import com.takeoffmediareactnativepenthera.virtuoso.errors.PentheraErrors
|
|
37
|
+
import java.text.SimpleDateFormat
|
|
38
|
+
import java.util.Calendar
|
|
39
39
|
import java.util.UUID
|
|
40
40
|
|
|
41
41
|
class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
@@ -44,7 +44,6 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
44
44
|
var asset: IAsset? = null
|
|
45
45
|
val assetId: MutableList<String> = mutableListOf()
|
|
46
46
|
private val gson = Gson()
|
|
47
|
-
private val client = OkHttpClient()
|
|
48
47
|
var minimumLowBandWidth: Double = 0.5 // 500kbps
|
|
49
48
|
val mService: IService = virtuoso.service
|
|
50
49
|
private val enginePauseObserver = object: EngineObserver() {
|
|
@@ -280,33 +279,36 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
280
279
|
}
|
|
281
280
|
|
|
282
281
|
|
|
283
|
-
fun getByAssetId(assetId: String): String? {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
fun getByAssetId(assetId: String): String? {
|
|
283
|
+
try {
|
|
284
|
+
// load asset if it has already been downloaded
|
|
285
|
+
val list: MutableList<IIdentifier> = virtuoso.assetManager.getByAssetId(assetId)
|
|
287
286
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
list.let {
|
|
288
|
+
if (it.isNotEmpty()) {
|
|
289
|
+
asset = list[0] as VirtuosoSegmentedFile
|
|
291
290
|
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
// This a workaround to work with ancillary files
|
|
292
|
+
val offlineUrl = asset?.playbackURL
|
|
294
293
|
|
|
295
|
-
|
|
296
|
-
keyValueMap["offlineUrl"] = offlineUrl.toString()
|
|
297
|
-
keyValueMap["metadata"] = asset?.metadata.toString()
|
|
294
|
+
(offlineUrl?.openConnection() as HttpURLConnection).connect()
|
|
298
295
|
|
|
299
|
-
|
|
296
|
+
val keyValueMap = HashMap<String, Any>()
|
|
297
|
+
keyValueMap["offlineUrl"] = offlineUrl.toString()
|
|
298
|
+
keyValueMap["metadata"] = asset?.metadata.toString()
|
|
300
299
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
300
|
+
val ancillaryFiles = (asset as ISegmentedAsset).getAncillaryFiles(context)
|
|
301
|
+
|
|
302
|
+
keyValueMap["ancillary"] = ancillaryFiles
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
return gson.toJson(keyValueMap)
|
|
305
306
|
}
|
|
306
|
-
} catch (e: Exception) {
|
|
307
|
-
e.printStackTrace()
|
|
308
307
|
}
|
|
309
|
-
|
|
308
|
+
} catch (e: Exception) {
|
|
309
|
+
e.printStackTrace()
|
|
310
|
+
}
|
|
311
|
+
return null
|
|
310
312
|
}
|
|
311
313
|
|
|
312
314
|
private fun toSubtitleMimeType(format: String?): String? {
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/ServiceStarter.kt
CHANGED
|
@@ -55,12 +55,14 @@ class ServiceStarter : VirtuosoServiceStarter() {
|
|
|
55
55
|
return currentNotification!!
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
override fun getForegroundServiceNotificationProvider(): Class
|
|
58
|
+
override fun getForegroundServiceNotificationProvider(): Class<*>? {
|
|
59
59
|
// Returning this class definition causes the service to instantiate and use the class
|
|
60
60
|
// from within the service process to generate all notifications relating to asset downloads.
|
|
61
61
|
// Returning null results in the classic SDK behaviour where all notifications are generated
|
|
62
62
|
// and delivered to the service via the service starter.
|
|
63
|
-
return ServiceForegroundNotificationProvider::class.java
|
|
63
|
+
// return ServiceForegroundNotificationProvider::class.java
|
|
64
|
+
return null
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
|
|
66
68
|
}
|