@takeoffmedia/react-native-penthera 0.2.55 → 0.2.57
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/AssetQueueObserver.kt +5 -3
- package/android/src/main/java/com/takeoffmediareactnativepenthera/PentheraModule.kt +2 -9
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt +4 -8
- package/package.json +1 -1
|
@@ -129,9 +129,11 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
129
129
|
} else if(assetStatus == "Downloading") {
|
|
130
130
|
Util.manageInternetSpeed(it.assetURL) { speedInMbps ->
|
|
131
131
|
val speedInKbps = speedInMbps * 1000
|
|
132
|
-
if (speedInMbps
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
if (speedInMbps > 0) {
|
|
133
|
+
if(speedInKbps <= mOfflineVideo.minimumLowBandWidth){
|
|
134
|
+
runOnUiThread {
|
|
135
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, it.assetId, PentheraErrors.LOW_BAND_WIDTH)
|
|
136
|
+
}
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
package com.takeoffmediareactnativepenthera
|
|
2
2
|
|
|
3
3
|
import EventEmitter
|
|
4
|
-
import android.app.Activity
|
|
5
4
|
import android.util.Log
|
|
6
|
-
import com.facebook.react.bridge.Arguments
|
|
7
5
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
8
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
8
|
import com.facebook.react.bridge.ReactMethod
|
|
11
9
|
import com.facebook.react.bridge.Promise
|
|
12
10
|
import com.facebook.react.bridge.ReadableArray
|
|
13
|
-
import com.facebook.react.bridge.ReadableMap
|
|
14
|
-
import com.facebook.react.bridge.WritableMap
|
|
15
11
|
import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
|
|
16
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
17
12
|
|
|
18
13
|
|
|
19
14
|
class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
20
15
|
|
|
21
16
|
private var offlineVideoEngine: OfflineVideoEngine = OfflineVideoEngine(reactContext)
|
|
22
|
-
private var activity: Activity? = null
|
|
23
17
|
private var appState: String = "active"
|
|
24
18
|
val reactContext: ReactApplicationContext = reactContext
|
|
25
19
|
|
|
@@ -28,7 +22,6 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
28
22
|
super.initialize()
|
|
29
23
|
|
|
30
24
|
EventEmitter.sharedInstance.registerEventEmitter(this)
|
|
31
|
-
activity = currentActivity
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
// Example method
|
|
@@ -40,12 +33,12 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
40
33
|
|
|
41
34
|
@ReactMethod
|
|
42
35
|
fun initializeSdk(user: String, backplaneUrl: String, publicKey: String, privateKey: String, promise: Promise) {
|
|
43
|
-
offlineVideoEngine?.setup(user, backplaneUrl, publicKey, privateKey,
|
|
36
|
+
offlineVideoEngine?.setup(user, backplaneUrl, publicKey, privateKey, promise)
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
@ReactMethod
|
|
47
40
|
fun download(data: String){
|
|
48
|
-
offlineVideoEngine?.downloadAsset(data
|
|
41
|
+
offlineVideoEngine?.downloadAsset(data)
|
|
49
42
|
}
|
|
50
43
|
@ReactMethod
|
|
51
44
|
fun getDownloads(blank: String, promise: Promise) {
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt
CHANGED
|
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
|
|
4
4
|
import android.app.Activity
|
|
5
5
|
import android.content.Context
|
|
6
6
|
import android.util.Log
|
|
7
|
-
import android.widget.Toast
|
|
8
7
|
import com.bitmovin.player.reactnative.PlayerModule
|
|
9
8
|
import com.bitmovin.player.reactnative.converter.JsonConverter
|
|
10
9
|
|
|
@@ -28,13 +27,11 @@ import com.facebook.react.bridge.Arguments
|
|
|
28
27
|
import com.facebook.react.uimanager.UIManagerModule
|
|
29
28
|
import com.facebook.react.bridge.Promise
|
|
30
29
|
import com.facebook.react.bridge.ReadableArray
|
|
31
|
-
import com.facebook.react.bridge.ReadableMap
|
|
32
30
|
import com.penthera.virtuososdk.client.AncillaryFile
|
|
33
31
|
import org.json.JSONArray
|
|
34
32
|
import org.json.JSONObject
|
|
35
33
|
import java.text.SimpleDateFormat
|
|
36
34
|
import java.util.Calendar
|
|
37
|
-
import java.util.TimeZone
|
|
38
35
|
|
|
39
36
|
class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
40
37
|
|
|
@@ -44,7 +41,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
44
41
|
var asset: IAsset? = null
|
|
45
42
|
var assetId: MutableList<String> = mutableListOf()
|
|
46
43
|
private val gson = Gson()
|
|
47
|
-
var minimumLowBandWidth:
|
|
44
|
+
var minimumLowBandWidth: Double = 0.00010
|
|
48
45
|
|
|
49
46
|
private val enginePauseObserver: Observers.IEngineObserver = object : EngineObserver() {
|
|
50
47
|
override fun engineStatusChanged(status: Int) {
|
|
@@ -52,7 +49,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
private fun
|
|
52
|
+
private fun getInstanceVirtuoso(): Virtuoso {
|
|
56
53
|
virtuoso = Virtuoso(context)
|
|
57
54
|
queueObserver = AssetQueueObserver(this, virtuoso)
|
|
58
55
|
onResume()
|
|
@@ -76,10 +73,9 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
76
73
|
backplaneUrl: String,
|
|
77
74
|
publicKey: String,
|
|
78
75
|
privateKey: String,
|
|
79
|
-
activity: Activity,
|
|
80
76
|
promise: Promise,
|
|
81
77
|
) {
|
|
82
|
-
val backplane =
|
|
78
|
+
val backplane = getInstanceVirtuoso()
|
|
83
79
|
val status = backplane.backplane?.authenticationStatus
|
|
84
80
|
val nameDevice = android.os.Build.MODEL
|
|
85
81
|
if (status == AuthenticationStatus.NOT_AUTHENTICATED) {
|
|
@@ -104,7 +100,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
104
100
|
}
|
|
105
101
|
|
|
106
102
|
|
|
107
|
-
fun downloadAsset(newItem: String
|
|
103
|
+
fun downloadAsset(newItem: String) {
|
|
108
104
|
val data = JSONObject(newItem)
|
|
109
105
|
val item = data["item"] as JSONObject
|
|
110
106
|
assetId.add(item["id"].toString())
|