@takeoffmedia/react-native-penthera 0.2.37 → 0.2.38
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.
|
@@ -9,6 +9,7 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
9
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
10
|
import com.facebook.react.bridge.ReactMethod
|
|
11
11
|
import com.facebook.react.bridge.Promise
|
|
12
|
+
import com.facebook.react.bridge.ReadableArray
|
|
12
13
|
import com.facebook.react.bridge.ReadableMap
|
|
13
14
|
import com.facebook.react.bridge.WritableMap
|
|
14
15
|
import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
|
|
@@ -17,7 +18,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEm
|
|
|
17
18
|
|
|
18
19
|
class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
19
20
|
|
|
20
|
-
private var offlineVideoEngine: OfflineVideoEngine
|
|
21
|
+
private var offlineVideoEngine: OfflineVideoEngine = OfflineVideoEngine(reactContext)
|
|
21
22
|
private var activity: Activity? = null
|
|
22
23
|
private var appState: String = "active"
|
|
23
24
|
val reactContext: ReactApplicationContext = reactContext
|
|
@@ -48,21 +49,22 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
48
49
|
}
|
|
49
50
|
@ReactMethod
|
|
50
51
|
fun getDownloads(blank: String, promise: Promise) {
|
|
51
|
-
promise.resolve(offlineVideoEngine
|
|
52
|
+
promise.resolve(offlineVideoEngine.getDownloads())
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
@ReactMethod
|
|
55
56
|
fun getByAssetId(assetId: String, promise: Promise) {
|
|
56
|
-
promise.resolve(offlineVideoEngine
|
|
57
|
+
promise.resolve(offlineVideoEngine.getByAssetId(assetId))
|
|
57
58
|
}
|
|
58
59
|
@ReactMethod
|
|
59
|
-
fun
|
|
60
|
-
offlineVideoEngine
|
|
60
|
+
fun deleteMany(assetIds: ReadableArray, promise: Promise) {
|
|
61
|
+
val result = offlineVideoEngine.deleteMany(assetIds, promise)
|
|
62
|
+
promise.resolve(result)
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
@ReactMethod
|
|
64
66
|
fun loadBitmovinSourceManager(assetId: String, nativeId: String, promise: Promise) {
|
|
65
|
-
val bitmovinSourceItem = offlineVideoEngine
|
|
67
|
+
val bitmovinSourceItem = offlineVideoEngine.loadBitmovinSourceManager(assetId, nativeId)
|
|
66
68
|
promise.resolve(bitmovinSourceItem)
|
|
67
69
|
}
|
|
68
70
|
@ReactMethod
|
|
@@ -79,7 +81,7 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
79
81
|
|
|
80
82
|
reactContext.addLifecycleEventListener(object : LifecycleEventListener {
|
|
81
83
|
override fun onHostResume() {
|
|
82
|
-
offlineVideoEngine
|
|
84
|
+
offlineVideoEngine.onResume()
|
|
83
85
|
appStateListener("active")
|
|
84
86
|
|
|
85
87
|
}
|
|
@@ -87,7 +89,7 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
87
89
|
|
|
88
90
|
|
|
89
91
|
override fun onHostPause() {
|
|
90
|
-
offlineVideoEngine
|
|
92
|
+
offlineVideoEngine.onPause()
|
|
91
93
|
appStateListener("background")
|
|
92
94
|
}
|
|
93
95
|
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt
CHANGED
|
@@ -33,9 +33,12 @@ import java.net.URL
|
|
|
33
33
|
import java.util.UUID
|
|
34
34
|
import com.bitmovin.player.reactnative.SourceModule
|
|
35
35
|
import com.bitmovin.player.reactnative.converter.JsonConverter
|
|
36
|
+
import com.facebook.react.bridge.Arguments
|
|
36
37
|
import com.facebook.react.bridge.ReadableMap
|
|
37
38
|
import com.facebook.react.uimanager.UIManagerModule
|
|
38
39
|
import com.facebook.react.bridge.Promise
|
|
40
|
+
import com.facebook.react.bridge.ReadableArray
|
|
41
|
+
import com.facebook.react.bridge.WritableMap
|
|
39
42
|
|
|
40
43
|
class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
41
44
|
|
|
@@ -171,28 +174,31 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
|
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
|
|
174
|
-
fun deleteAsset(assetId: String) {
|
|
175
|
-
//load asset if it has already been downloaded
|
|
176
|
-
val list: MutableList<IIdentifier>? = virtuoso.assetManager?.getByAssetId(assetId)
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
178
|
+
fun deleteMany(assetIds: ReadableArray, promise: Promise) {
|
|
179
|
+
val assetManager = virtuoso.assetManager
|
|
180
|
+
val result = Arguments.createMap()
|
|
181
|
+
|
|
182
|
+
for (i in 0 until assetIds.size()) {
|
|
183
|
+
val assetId = assetIds.getString(i)
|
|
184
|
+
val asset = assetManager.getByAssetId(assetId)
|
|
185
|
+
.firstOrNull() as? IAsset
|
|
186
|
+
|
|
187
|
+
if (asset != null) {
|
|
188
|
+
assetManager.delete(asset)
|
|
189
|
+
result.putBoolean(assetId, true)
|
|
190
|
+
} else {
|
|
191
|
+
result.putBoolean(assetId, false)
|
|
192
|
+
}
|
|
189
193
|
}
|
|
190
194
|
|
|
195
|
+
promise.resolve(result);
|
|
191
196
|
}
|
|
192
197
|
|
|
198
|
+
|
|
193
199
|
fun getByAssetId(assetId: String): String? {
|
|
194
200
|
//load asset if it has already been downloaded
|
|
195
|
-
val list: MutableList<IIdentifier>? = virtuoso.assetManager
|
|
201
|
+
val list: MutableList<IIdentifier>? = virtuoso.assetManager.getByAssetId(assetId)
|
|
196
202
|
|
|
197
203
|
list?.let {
|
|
198
204
|
if (it.isNotEmpty()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeoffmedia/react-native-penthera",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"description": "test",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -166,4 +166,4 @@
|
|
|
166
166
|
"dependencies": {
|
|
167
167
|
"zustand": "^4.4.0"
|
|
168
168
|
}
|
|
169
|
-
}
|
|
169
|
+
}
|