@takeoffmedia/react-native-penthera 0.2.67 → 0.3.1
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 +117 -94
- package/android/src/main/java/com/takeoffmediareactnativepenthera/EventEmitter.kt +23 -12
- package/android/src/main/java/com/takeoffmediareactnativepenthera/PentheraModule.kt +55 -39
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/DemoLicenseManager.kt +0 -14
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/OfflineVideoEngine.kt +235 -177
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/data/Item.kt +0 -18
- package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/notification/NotificationFactory.kt +11 -8
- package/android/src/main/res/values/colors.xml +1 -0
- package/lib/commonjs/hooks/usePenthera/usePentheraInit.js +69 -0
- package/lib/commonjs/hooks/usePenthera/usePentheraInit.js.map +1 -1
- package/lib/commonjs/nativeModules/index.js +8 -0
- package/lib/commonjs/nativeModules/index.js.map +1 -1
- package/lib/module/hooks/usePenthera/usePentheraInit.js +68 -0
- package/lib/module/hooks/usePenthera/usePentheraInit.js.map +1 -1
- package/lib/module/nativeModules/index.js +6 -0
- package/lib/module/nativeModules/index.js.map +1 -1
- package/lib/typescript/hooks/usePenthera/usePentheraInit.d.ts +5 -0
- package/lib/typescript/hooks/usePenthera/usePentheraInit.d.ts.map +1 -1
- package/lib/typescript/nativeModules/index.d.ts +2 -0
- package/lib/typescript/nativeModules/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/hooks/usePenthera/usePentheraInit.tsx +70 -0
- package/src/nativeModules/index.ts +8 -0
- package/ios/Penthera.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Penthera.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Penthera.xcodeproj/project.xcworkspace/xcuserdata/joseguerreroot.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -104
- package/ios/Penthera.xcodeproj/xcuserdata/joseguerreroot.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -9,44 +9,68 @@ import com.penthera.virtuososdk.client.Observers
|
|
|
9
9
|
import com.penthera.virtuososdk.client.Virtuoso
|
|
10
10
|
import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
|
|
11
11
|
import com.takeoffmediareactnativepenthera.virtuoso.errors.PentheraErrors
|
|
12
|
-
import com.takeoffmediareactnativepenthera.virtuoso.util.Util
|
|
13
|
-
|
|
14
12
|
|
|
15
13
|
class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso) : Observers.IQueueObserver {
|
|
16
14
|
|
|
17
15
|
private var lastProgress : Int = -1
|
|
18
|
-
private var
|
|
19
|
-
private var
|
|
16
|
+
private var mOfflineVideo : OfflineVideoEngine = mOfflineVideo
|
|
17
|
+
private var instanceVirtuoso: Virtuoso = virtuoso
|
|
18
|
+
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
override fun engineStartedDownloadingAsset(aAsset: IIdentifier) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mOfflineVideo.assetId.
|
|
22
|
+
try {
|
|
23
|
+
val updateAsset = aAsset as IAsset
|
|
24
|
+
val assetId = updateAsset.assetId
|
|
25
|
+
if (!mOfflineVideo.assetId.contains(assetId)) {
|
|
26
|
+
mOfflineVideo.assetId.add(assetId)
|
|
27
|
+
}
|
|
28
|
+
lastProgress = -1
|
|
29
|
+
updateItem(aAsset, true)
|
|
30
|
+
val eventCategory = "penthera"
|
|
31
|
+
val eventType = PentheraEvent.DID_START_DOWNLOADING
|
|
32
|
+
EventEmitter.sharedInstance.dispatch(eventCategory, eventType, assetId, "")
|
|
33
|
+
} catch (e: Exception) {
|
|
34
|
+
// Handle the exception here, for example, log it
|
|
35
|
+
Log.e("MiModulo", "Error in engineStartedDownloadingAsset", e)
|
|
27
36
|
}
|
|
28
|
-
lastProgress = -1
|
|
29
|
-
updateItem(aAsset, true)
|
|
30
|
-
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.DID_START_DOWNLOADING, assetId, "")
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
override fun enginePerformedProgressUpdateDuringDownload(aAsset: IIdentifier) {
|
|
34
|
-
|
|
40
|
+
try {
|
|
41
|
+
updateItem(aAsset, true)
|
|
42
|
+
} catch (e: Exception) {
|
|
43
|
+
// Handle the exception here, for example, log it
|
|
44
|
+
Log.e("MiModulo", "Error in enginePerformedProgressUpdateDuringDownload", e)
|
|
45
|
+
}
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
override fun engineCompletedDownloadingAsset(aAsset: IIdentifier) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
try {
|
|
50
|
+
val updateAsset = aAsset as IAsset
|
|
51
|
+
val assetId = updateAsset.assetId
|
|
52
|
+
updateItem(aAsset, true)
|
|
53
|
+
val eventCategory = "penthera"
|
|
54
|
+
val eventType = PentheraEvent.DOWNLOAD_COMPLETE
|
|
55
|
+
EventEmitter.sharedInstance.dispatch(eventCategory, eventType, assetId, "")
|
|
56
|
+
mOfflineVideo.assetId.remove(assetId)
|
|
57
|
+
} catch (e: Exception) {
|
|
58
|
+
// Handle the exception here, for example, log it
|
|
59
|
+
Log.e("MiModulo", "Error in engineCompletedDownloadingAsset", e)
|
|
60
|
+
}
|
|
43
61
|
}
|
|
44
62
|
|
|
45
63
|
override fun engineEncounteredErrorDownloadingAsset(aAsset: IIdentifier) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
try {
|
|
65
|
+
val asset = aAsset as IAsset
|
|
66
|
+
val logTag = "MiModulo"
|
|
67
|
+
val logMessage = "<<<<<<<<<<engineEncounteredErrorDownloadingAsset>>>>>>>>>>>>"
|
|
68
|
+
Log.e(logTag, logMessage)
|
|
69
|
+
updateItemStatus(asset, false)
|
|
70
|
+
} catch (e: Exception) {
|
|
71
|
+
// Handle the exception here, for example, log it
|
|
72
|
+
Log.e("MiModulo", "Error in engineEncounteredErrorDownloadingAsset", e)
|
|
73
|
+
}
|
|
50
74
|
}
|
|
51
75
|
|
|
52
76
|
override fun engineEncounteredErrorParsingAsset(mAssetId: String) {
|
|
@@ -57,94 +81,93 @@ class AssetQueueObserver(mOfflineVideo : OfflineVideoEngine, virtuoso: Virtuoso)
|
|
|
57
81
|
override fun engineUpdatedQueue() {
|
|
58
82
|
// This indicates a change to the download queue - meaning either we added or removed something
|
|
59
83
|
Log.e("MiModulo","<<<<<<<<<<engineUpdatedQueue>>>>>>>>>>>>")
|
|
60
|
-
|
|
61
84
|
}
|
|
62
85
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
private fun updateItem(aFile: IIdentifier, forceUpdate: Boolean) {
|
|
87
|
+
try {
|
|
88
|
+
val logTag = "MiModulo"
|
|
89
|
+
val logMessage = "<<<<<<<<<<updateItem>>>>>>>>>>>>"
|
|
90
|
+
Log.e(logTag, logMessage)
|
|
91
|
+
val updateAsset = aFile as IAsset
|
|
92
|
+
val assetId = updateAsset.assetId
|
|
93
|
+
// Progress is for catalog item
|
|
94
|
+
if (assetId.isNotEmpty() && assetId in mOfflineVideo.assetId) {
|
|
95
|
+
//update our asset status
|
|
96
|
+
updateItemStatus(updateAsset, forceUpdate)
|
|
97
|
+
}
|
|
98
|
+
} catch (e: Exception) {
|
|
99
|
+
// Handle the exception here, for example, log it
|
|
100
|
+
Log.e("MiModulo", "Error in updateItem", e)
|
|
73
101
|
}
|
|
74
102
|
}
|
|
75
103
|
|
|
76
104
|
private fun updateItemStatus(asset: IAsset?, forceUpdate: Boolean) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
assetStatus = "Error"
|
|
108
|
-
value = PentheraErrors.DOWNLOAD_DENIED_COPIES
|
|
109
|
-
}
|
|
110
|
-
//Max simultaneous download-enabled devices per account: 5
|
|
111
|
-
Common.AssetStatus.DOWNLOAD_DENIED_ASSET -> {
|
|
112
|
-
assetStatus = "Error"
|
|
113
|
-
value = PentheraErrors.DOWNLOAD_DENIED_ASSET
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
else -> {
|
|
118
|
-
if(allowableStorageRemaining == 0L) {
|
|
105
|
+
try {
|
|
106
|
+
val logTag = "MiModulo"
|
|
107
|
+
val logMessage = "<<<<<<<<<<updateItemStatus>>>>>>>>>>>>"
|
|
108
|
+
Log.e(logTag, logMessage)
|
|
109
|
+
asset?.let{
|
|
110
|
+
if(it.assetId in mOfflineVideo.assetId){
|
|
111
|
+
mOfflineVideo.asset = asset
|
|
112
|
+
val progress = (asset.fractionComplete * 100.0).toInt()
|
|
113
|
+
if (forceUpdate || progress != lastProgress) {
|
|
114
|
+
val assetStatus : String
|
|
115
|
+
val value: String
|
|
116
|
+
val status = asset.downloadStatus
|
|
117
|
+
|
|
118
|
+
val allowableStorageRemaining = instanceVirtuoso.allowableStorageRemaining
|
|
119
|
+
when (status) {
|
|
120
|
+
Common.AssetStatus.DOWNLOADING -> {
|
|
121
|
+
assetStatus = "Downloading"
|
|
122
|
+
value = "downloading"
|
|
123
|
+
}
|
|
124
|
+
Common.AssetStatus.DOWNLOAD_COMPLETE -> {
|
|
125
|
+
assetStatus = "complete"
|
|
126
|
+
value = "complete"
|
|
127
|
+
}
|
|
128
|
+
// Max simultaneous downloaded assets across account: 10
|
|
129
|
+
Common.AssetStatus.DOWNLOAD_DENIED_ACCOUNT -> {
|
|
130
|
+
assetStatus = "Error"
|
|
131
|
+
value = PentheraErrors.DOWNLOAD_DENIED_MAX_DEVICE_DOWNLOADS
|
|
132
|
+
}
|
|
133
|
+
// Max simultaneous copies of an asset across account: 1
|
|
134
|
+
Common.AssetStatus.DOWNLOAD_DENIED_COPIES -> {
|
|
119
135
|
assetStatus = "Error"
|
|
120
|
-
value =
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
value = PentheraErrors.DOWNLOAD_DENIED_COPIES
|
|
137
|
+
}
|
|
138
|
+
//Max simultaneous download-enabled devices per account: 5
|
|
139
|
+
Common.AssetStatus.DOWNLOAD_DENIED_ASSET -> {
|
|
140
|
+
assetStatus = "Error"
|
|
141
|
+
value = PentheraErrors.DOWNLOAD_DENIED_ASSET
|
|
142
|
+
}
|
|
143
|
+
else -> {
|
|
144
|
+
if(allowableStorageRemaining == 0L) {
|
|
145
|
+
assetStatus = "Error"
|
|
146
|
+
value = "Insufficient storage for download"
|
|
147
|
+
} else {
|
|
148
|
+
assetStatus = "Queued"
|
|
149
|
+
value = "pending"
|
|
150
|
+
}
|
|
124
151
|
}
|
|
125
152
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if(speedInKbps <= mOfflineVideo.minimumLowBandWidth){
|
|
135
|
-
runOnUiThread {
|
|
136
|
-
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, it.assetId, PentheraErrors.LOW_BAND_WIDTH)
|
|
137
|
-
}
|
|
153
|
+
val hasError = assetStatus == "Error"
|
|
154
|
+
if(hasError){
|
|
155
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, it.assetId, value)
|
|
156
|
+
} else if(assetStatus == "Downloading") {
|
|
157
|
+
val speedInMbs = mOfflineVideo.mService.windowedThroughput
|
|
158
|
+
runOnUiThread {
|
|
159
|
+
if(speedInMbs <= mOfflineVideo.minimumLowBandWidth && progress > 1){
|
|
160
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.ERROR_DOWNLOAD, it.assetId, PentheraErrors.LOW_BAND_WIDTH)
|
|
138
161
|
}
|
|
139
162
|
}
|
|
163
|
+
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.PROGRESS_UPDATED, it.assetId, progress.toString())
|
|
140
164
|
}
|
|
141
|
-
EventEmitter.sharedInstance.dispatch("penthera", PentheraEvent.PROGRESS_UPDATED, it.assetId, progress.toString())
|
|
142
165
|
}
|
|
143
166
|
}
|
|
144
167
|
}
|
|
168
|
+
} catch (e: Exception) {
|
|
169
|
+
// Handle the exception here, for example, log it
|
|
170
|
+
Log.e("MiModulo", "Error in updateItemStatus", e)
|
|
145
171
|
}
|
|
146
172
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
173
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
package com.takeoffmediareactnativepenthera
|
|
2
|
+
|
|
3
3
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
4
|
-
import com.facebook.react.bridge.WritableMap
|
|
5
4
|
import com.google.gson.Gson
|
|
6
|
-
import com.takeoffmediareactnativepenthera.PentheraModule
|
|
7
5
|
|
|
8
6
|
object PentheraEvent {
|
|
9
7
|
const val DID_START_DOWNLOADING = "DID_START_DOWNLOADING"
|
|
@@ -21,6 +19,10 @@ object PentheraEvent {
|
|
|
21
19
|
const val ERROR_DOWNLOAD = "ERROR_DOWNLOAD"
|
|
22
20
|
}
|
|
23
21
|
|
|
22
|
+
private val gson = Gson()
|
|
23
|
+
|
|
24
|
+
data class Event(val code: String, val assetId: String, val body: String)
|
|
25
|
+
|
|
24
26
|
class EventEmitter private constructor() {
|
|
25
27
|
companion object {
|
|
26
28
|
val sharedInstance: EventEmitter by lazy { EventEmitter() }
|
|
@@ -34,20 +36,29 @@ class EventEmitter private constructor() {
|
|
|
34
36
|
|
|
35
37
|
fun dispatch(name: String, code: String, assetId: String, body: String) {
|
|
36
38
|
val event = Event(code, assetId, body)
|
|
37
|
-
val gson = Gson()
|
|
38
39
|
val json = gson.toJson(event)
|
|
39
40
|
val reactContext = eventEmitter?.reactContext
|
|
40
|
-
reactContext
|
|
41
|
+
reactContext?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
41
42
|
?.emit(name, json)
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
val allEvents: List<String> by lazy {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
listOf(
|
|
47
|
+
"penthera",
|
|
48
|
+
PentheraEvent.DID_START_DOWNLOADING,
|
|
49
|
+
PentheraEvent.PROGRESS_UPDATED,
|
|
50
|
+
PentheraEvent.DOWNLOAD_COMPLETE,
|
|
51
|
+
PentheraEvent.CONFIG_ASSET_FAILED,
|
|
52
|
+
PentheraEvent.ASSET_RESUME_DOWNLOAD_UPDATED,
|
|
53
|
+
PentheraEvent.ASSET_DELETED,
|
|
54
|
+
PentheraEvent.FAIR_PLAY_FAILED_INIT_DELEGATE,
|
|
55
|
+
PentheraEvent.FAIR_PLAY_EXTRACT_CID,
|
|
56
|
+
PentheraEvent.FAIR_PLAY_PREPARE_SPC,
|
|
57
|
+
PentheraEvent.FAIR_PLAY_EXTRACT_CKC,
|
|
58
|
+
PentheraEvent.FAIR_PLAY_LICENSE_DELEGATE_ERROR,
|
|
59
|
+
PentheraEvent.PENDING_ASSET_FOUND,
|
|
60
|
+
PentheraEvent.ERROR_DOWNLOAD
|
|
61
|
+
)
|
|
50
62
|
}
|
|
51
63
|
|
|
52
|
-
private class Event(val code: String, val assetId: String, val body: String)
|
|
53
64
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.takeoffmediareactnativepenthera
|
|
2
2
|
|
|
3
|
-
import EventEmitter
|
|
4
3
|
import android.util.Log
|
|
5
4
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
6
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -8,28 +7,31 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
|
8
7
|
import com.facebook.react.bridge.ReactMethod
|
|
9
8
|
import com.facebook.react.bridge.Promise
|
|
10
9
|
import com.facebook.react.bridge.ReadableArray
|
|
11
|
-
import com.facebook.react.bridge.UiThreadUtil.runOnUiThread
|
|
12
10
|
import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
|
|
13
|
-
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
14
|
-
import kotlinx.coroutines.GlobalScope
|
|
15
|
-
import kotlinx.coroutines.launch
|
|
16
11
|
import com.facebook.react.uimanager.UIManagerModule
|
|
17
12
|
|
|
13
|
+
private enum class AppState {
|
|
14
|
+
ACTIVE,
|
|
15
|
+
BACKGROUND,
|
|
16
|
+
INACTIVE
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
19
|
+
class PentheraModule(val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
20
20
|
|
|
21
|
-
private
|
|
22
|
-
private var appState
|
|
23
|
-
|
|
21
|
+
private val offlineVideoEngine = OfflineVideoEngine(reactContext)
|
|
22
|
+
private var appState = AppState.ACTIVE
|
|
23
|
+
private var lifecycleEventListener: LifecycleEventListener? = null
|
|
24
24
|
|
|
25
25
|
override fun getName(): String = NAME
|
|
26
|
+
|
|
26
27
|
override fun initialize() {
|
|
27
28
|
super.initialize()
|
|
28
|
-
|
|
29
29
|
EventEmitter.sharedInstance.registerEventEmitter(this)
|
|
30
30
|
}
|
|
31
|
+
|
|
31
32
|
private fun uiManager(): UIManagerModule? =
|
|
32
33
|
reactContext.getNativeModule(UIManagerModule::class.java)
|
|
34
|
+
|
|
33
35
|
// Example method
|
|
34
36
|
// See https://reactnative.dev/docs/native-modules-android
|
|
35
37
|
@ReactMethod
|
|
@@ -39,28 +41,38 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
39
41
|
|
|
40
42
|
@ReactMethod
|
|
41
43
|
fun initializeSdk(user: String, backplaneUrl: String, publicKey: String, privateKey: String, promise: Promise) {
|
|
42
|
-
offlineVideoEngine
|
|
44
|
+
offlineVideoEngine.setup(user, backplaneUrl, publicKey, privateKey, promise)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactMethod
|
|
48
|
+
fun onResume() {
|
|
49
|
+
offlineVideoEngine.onResume()
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
@ReactMethod
|
|
46
53
|
fun download(data: String){
|
|
47
|
-
offlineVideoEngine
|
|
54
|
+
offlineVideoEngine.downloadAsset(data)
|
|
48
55
|
}
|
|
56
|
+
|
|
49
57
|
@ReactMethod
|
|
50
58
|
fun getDownloads(blank: String, promise: Promise) {
|
|
51
|
-
|
|
59
|
+
offlineVideoEngine.getDownloads(promise)
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
@ReactMethod
|
|
55
63
|
fun getByAssetId(assetId: String, promise: Promise) {
|
|
56
64
|
promise.resolve(offlineVideoEngine.getByAssetId(assetId))
|
|
57
65
|
}
|
|
66
|
+
|
|
58
67
|
@ReactMethod
|
|
59
68
|
fun deleteMany(assetIds: ReadableArray, promise: Promise) {
|
|
60
|
-
|
|
61
|
-
promise.resolve(result)
|
|
69
|
+
offlineVideoEngine.deleteMany(assetIds, promise)
|
|
62
70
|
}
|
|
63
71
|
|
|
72
|
+
@ReactMethod
|
|
73
|
+
fun getAuthenticationStatus(promise: Promise) {
|
|
74
|
+
offlineVideoEngine.getAuthenticationStatus(promise)
|
|
75
|
+
}
|
|
64
76
|
|
|
65
77
|
@ReactMethod
|
|
66
78
|
fun loadBitmovinSourceManager(assetId: String, nativeId: String, startOffset: Double?, ancillaryFiles: String, promise: Promise) {
|
|
@@ -70,36 +82,41 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
70
82
|
promise.resolve(bitmovinSourceItem)
|
|
71
83
|
}
|
|
72
84
|
}
|
|
85
|
+
|
|
73
86
|
@ReactMethod
|
|
74
87
|
fun startAppStateListener() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
if (lifecycleEventListener == null) {
|
|
89
|
+
lifecycleEventListener = object : LifecycleEventListener {
|
|
90
|
+
override fun onHostResume() {
|
|
91
|
+
offlineVideoEngine.onResume()
|
|
92
|
+
handleAppStateChange(AppState.ACTIVE)
|
|
93
|
+
}
|
|
94
|
+
override fun onHostPause() {
|
|
95
|
+
offlineVideoEngine.onPause()
|
|
96
|
+
handleAppStateChange(AppState.BACKGROUND)
|
|
97
|
+
}
|
|
98
|
+
override fun onHostDestroy() {
|
|
99
|
+
handleAppStateChange(AppState.INACTIVE)
|
|
100
|
+
}
|
|
81
101
|
}
|
|
82
|
-
|
|
102
|
+
reactContext.addLifecycleEventListener(lifecycleEventListener)
|
|
83
103
|
}
|
|
104
|
+
}
|
|
84
105
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
override fun onHostPause() {
|
|
95
|
-
offlineVideoEngine.onPause()
|
|
96
|
-
appStateListener("background")
|
|
106
|
+
private fun handleAppStateChange(nextAppState: AppState) {
|
|
107
|
+
if (appState != nextAppState) {
|
|
108
|
+
when (nextAppState) {
|
|
109
|
+
AppState.ACTIVE -> Log.e("MiModulo", "active")
|
|
110
|
+
AppState.BACKGROUND -> Log.e("MiModulo", "background")
|
|
111
|
+
else -> { /* Do nothing */ }
|
|
97
112
|
}
|
|
113
|
+
appState = nextAppState
|
|
114
|
+
}
|
|
115
|
+
}
|
|
98
116
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
117
|
+
@ReactMethod
|
|
118
|
+
fun configParameters(params: String, promise: Promise) {
|
|
119
|
+
offlineVideoEngine.configParameters(params, promise)
|
|
103
120
|
}
|
|
104
121
|
|
|
105
122
|
@ReactMethod
|
|
@@ -112,7 +129,6 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
112
129
|
// Keep: Required for RN built in Event Emitter Calls.
|
|
113
130
|
}
|
|
114
131
|
|
|
115
|
-
|
|
116
132
|
companion object {
|
|
117
133
|
const val NAME = "Penthera"
|
|
118
134
|
}
|
package/android/src/main/java/com/takeoffmediareactnativepenthera/virtuoso/DemoLicenseManager.kt
CHANGED
|
@@ -10,10 +10,8 @@ package com.takeoffmediareactnativepenthera.virtuoso
|
|
|
10
10
|
import com.google.gson.Gson
|
|
11
11
|
import com.penthera.virtuososdk.client.drm.LicenseManager
|
|
12
12
|
import com.takeoffmediareactnativepenthera.virtuoso.data.Drm
|
|
13
|
-
import com.takeoffmediareactnativepenthera.virtuoso.data.Item
|
|
14
13
|
import org.json.JSONObject
|
|
15
14
|
|
|
16
|
-
// Used if implementing executeKeyRequest
|
|
17
15
|
/**
|
|
18
16
|
* A basic license manager implementation which provides the widevine url.
|
|
19
17
|
*
|
|
@@ -35,16 +33,4 @@ class DemoLicenseManager : LicenseManager() {
|
|
|
35
33
|
val drm = Gson().fromJson(data["drmContent"].toString(), Drm::class.java)
|
|
36
34
|
return drm.headers ?: mapOf()
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Override the following to perform more complex manipulation of the request and response,
|
|
42
|
-
// for instance if you need to parse a json response to retrieve the key response in base64
|
|
43
|
-
// You will also need to implement a post request method to support this implementation.
|
|
44
|
-
/*
|
|
45
|
-
public byte[] executeKeyRequest(UUID uuid, MediaDrm.KeyRequest request) throws IOException {
|
|
46
|
-
String url = getLicenseAcquistionUrl();
|
|
47
|
-
return post(url, request.getData(), getKeyRequestProperties());
|
|
48
|
-
}
|
|
49
|
-
*/
|
|
50
36
|
}
|