vdocipher-rn-bridge 1.17.0 → 1.17.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/CHANGELOG.md +3 -0
- package/android/build.gradle +2 -2
- package/downloads.ts +2 -24
- package/ios/RCTVdoPlayerUIView.swift +4 -42
- package/ios/RCTVdoPlayerView.swift +4 -41
- package/ios/VdoCipherRNView.swift +82 -3
- package/ios/VdoDownload.swift +372 -22
- package/ios/VdocipherRnBridgeViewManager.m +8 -1
- package/ios/VdocipherRnBridgeViewManager.swift +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -18,8 +18,8 @@ apply plugin: 'com.android.library'
|
|
|
18
18
|
// TODO read from package.json
|
|
19
19
|
// "releaseVersionName" must be the same as "version" in package.json
|
|
20
20
|
// "releaseVersionCode" must increment by 1 with every release
|
|
21
|
-
def releaseVersionName = "1.17.
|
|
22
|
-
def releaseVersionCode =
|
|
21
|
+
def releaseVersionName = "1.17.1"
|
|
22
|
+
def releaseVersionCode = 22
|
|
23
23
|
|
|
24
24
|
android {
|
|
25
25
|
compileSdkVersion 33
|
package/downloads.ts
CHANGED
|
@@ -14,11 +14,8 @@ const { VdoDownload } = NativeModules;
|
|
|
14
14
|
|
|
15
15
|
const getDownloadOptions = (optionParams: VdoTypes.OfflineOptionParams) => {
|
|
16
16
|
|
|
17
|
-
if (Platform.OS ==
|
|
18
|
-
console.warn("
|
|
19
|
-
return new Promise(function(resolve, reject) {
|
|
20
|
-
reject({errorCode: -1, errorMsg: "Download methods not supported in iOS", httpStatusCode: -1});
|
|
21
|
-
});
|
|
17
|
+
if (optionParams.customPlayerId != null && Platform.OS == "ios") {
|
|
18
|
+
console.warn("customPlayerId will not be used for ios, instead default Custom Player config will be used");
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
return new Promise(function(resolve, reject) {
|
|
@@ -39,12 +36,6 @@ const getDownloadOptions = (optionParams: VdoTypes.OfflineOptionParams) => {
|
|
|
39
36
|
|
|
40
37
|
const getEnqueueFn = (nativeId: string) => (downloadOptions: {selections: Array<number>}) => {
|
|
41
38
|
|
|
42
|
-
if (Platform.OS == 'ios') {
|
|
43
|
-
console.warn("Download methods not supported in iOS");
|
|
44
|
-
return new Promise(function(resolve, reject) {
|
|
45
|
-
reject({exception: null, msg: "Download methods not supported in iOS"});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
39
|
|
|
49
40
|
return new Promise<void>(function(resolve, reject) {
|
|
50
41
|
const requestOptions = {
|
|
@@ -67,12 +58,6 @@ const getEnqueueFn = (nativeId: string) => (downloadOptions: {selections: Array<
|
|
|
67
58
|
|
|
68
59
|
const query = (queryFilters: {mediaId: Array<string>, status: Array<string>}) => {
|
|
69
60
|
|
|
70
|
-
if (Platform.OS == 'ios') {
|
|
71
|
-
console.warn("Download methods not supported in iOS");
|
|
72
|
-
return new Promise(function(resolve, reject) {
|
|
73
|
-
reject({exception: "", msg: "Download methods not supported in iOS"});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
61
|
|
|
77
62
|
return new Promise(function(resolve, reject) {
|
|
78
63
|
VdoDownload.query(
|
|
@@ -90,13 +75,6 @@ const query = (queryFilters: {mediaId: Array<string>, status: Array<string>}) =>
|
|
|
90
75
|
|
|
91
76
|
const remove = (mediaIds: Array<string>) => {
|
|
92
77
|
|
|
93
|
-
if (Platform.OS == 'ios') {
|
|
94
|
-
console.warn("Download methods not supported in iOS");
|
|
95
|
-
return new Promise(function(resolve, reject) {
|
|
96
|
-
reject({exception: "", msg: "Download methods not supported in iOS"});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
78
|
return new Promise<void>(function(resolve, reject) {
|
|
101
79
|
VdoDownload.remove(
|
|
102
80
|
mediaIds,
|
|
@@ -26,49 +26,11 @@ class RCTVdoPlayerUIView: VdoCipherRNView {
|
|
|
26
26
|
self.addSubview(playerViewController.view)
|
|
27
27
|
playerViewController.didMove(toParent: self.reactViewController())
|
|
28
28
|
self.reactViewController().navigationController?.delegate = self
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let errorDescription = ErrorDescription(errorCode: 4101,
|
|
34
|
-
errorMsg: "Error: 4101 Invalid video parameters. Please contact the app developer.",
|
|
35
|
-
httpStatusCode: -1)
|
|
36
|
-
self.sendErrorEventWithDescription(errorDescription)
|
|
37
|
-
return
|
|
29
|
+
if embedInfo["offline"] as? Bool == true {
|
|
30
|
+
self.parseOfflineCredentials(fromInfo: embedInfo)
|
|
31
|
+
} else {
|
|
32
|
+
self.parseOnlineCredentials(fromInfo: embedInfo)
|
|
38
33
|
}
|
|
39
|
-
let customPlayerId = embedInfo["customPlayerId"] as? String
|
|
40
|
-
let preferredCaptionsLanguage = embedInfo["preferredCaptionsLanguage"] as? String
|
|
41
|
-
let enableAutoResume = embedInfo["enableAutoResume"] as? Bool
|
|
42
|
-
if enableAutoResume == false {
|
|
43
|
-
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.VdoFramework")
|
|
44
|
-
if var assetsLastPlaybackTimeSet = userDefaults?.value(forKey: "assetsLastPlaybackTimeSet") as? [String: Double] {
|
|
45
|
-
assetsLastPlaybackTimeSet[parsed.videoId] = Double(0)
|
|
46
|
-
userDefaults?.set(assetsLastPlaybackTimeSet, forKey: "assetsLastPlaybackTimeSet")
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
VdoAsset.createAsset(videoId: parsed.videoId, playerId: customPlayerId, onLoad: { asset, err in
|
|
50
|
-
DispatchQueue.main.async {
|
|
51
|
-
guard let asset = asset else {
|
|
52
|
-
if let error = err {
|
|
53
|
-
let errorDescription = ErrorDescription(errorCode: error.code, errorMsg: error.message, httpStatusCode: -1)
|
|
54
|
-
self.sendErrorEventWithDescription(errorDescription)
|
|
55
|
-
}
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
self.asset = asset
|
|
59
|
-
TrackSelection.asset = asset
|
|
60
|
-
if preferredCaptionsLanguage?.isEmpty == false {
|
|
61
|
-
DispatchQueue.main.async {
|
|
62
|
-
_ = self.setCaptionLanguage(lanCode: preferredCaptionsLanguage)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if asset.downloadState == .downloaded {
|
|
66
|
-
asset.playOffline()
|
|
67
|
-
} else {
|
|
68
|
-
asset.playOnline(otp: otp, playbackInfo: playbackInfo)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
34
|
})
|
|
73
35
|
}
|
|
74
36
|
}
|
|
@@ -21,48 +21,11 @@ class RCTVdoPlayerView: VdoCipherRNView {
|
|
|
21
21
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33 , execute: {
|
|
22
22
|
self.reactViewController().navigationController?.delegate = self
|
|
23
23
|
})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let errorDescription = ErrorDescription(errorCode: 4101,
|
|
29
|
-
errorMsg: "Error: 4101 Invalid video parameters. Please contact the app developer.",
|
|
30
|
-
httpStatusCode: -1)
|
|
31
|
-
self.sendErrorEventWithDescription(errorDescription)
|
|
32
|
-
return
|
|
24
|
+
if embedInfo["offline"] as? Bool == true {
|
|
25
|
+
self.parseOfflineCredentials(fromInfo: embedInfo)
|
|
26
|
+
} else {
|
|
27
|
+
self.parseOnlineCredentials(fromInfo: embedInfo)
|
|
33
28
|
}
|
|
34
|
-
let preferredCaptionsLanguage = embedInfo["preferredCaptionsLanguage"] as? String
|
|
35
|
-
let enableAutoResume = embedInfo["enableAutoResume"] as? Bool
|
|
36
|
-
if enableAutoResume == false {
|
|
37
|
-
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.VdoFramework")
|
|
38
|
-
if var assetsLastPlaybackTimeSet = userDefaults?.value(forKey: "assetsLastPlaybackTimeSet") as? [String: Double] {
|
|
39
|
-
assetsLastPlaybackTimeSet[parsed.videoId] = Double(0)
|
|
40
|
-
userDefaults?.set(assetsLastPlaybackTimeSet, forKey: "assetsLastPlaybackTimeSet")
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
VdoAsset.createAsset(videoId: parsed.videoId, onLoad: { asset, err in
|
|
44
|
-
DispatchQueue.main.async {
|
|
45
|
-
guard let asset = asset else {
|
|
46
|
-
if let error = err {
|
|
47
|
-
let errorDescription = ErrorDescription(errorCode: error.code, errorMsg: error.message, httpStatusCode: -1)
|
|
48
|
-
self.sendErrorEventWithDescription(errorDescription)
|
|
49
|
-
}
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
self.asset = asset
|
|
53
|
-
TrackSelection.asset = asset
|
|
54
|
-
if preferredCaptionsLanguage?.isEmpty == false {
|
|
55
|
-
DispatchQueue.main.async {
|
|
56
|
-
_ = self.setCaptionLanguage(lanCode: preferredCaptionsLanguage)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if asset.downloadState == .downloaded {
|
|
60
|
-
asset.playOffline()
|
|
61
|
-
} else {
|
|
62
|
-
asset.playOnline(otp: otp, playbackInfo: playbackInfo)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
29
|
}
|
|
67
30
|
|
|
68
31
|
override func playerReadyToPlay() {
|
|
@@ -18,6 +18,7 @@ class VdoCipherRNView: UIView {
|
|
|
18
18
|
private var progressTimer: Timer?
|
|
19
19
|
private var isLoaded = false
|
|
20
20
|
private var targetPlaybackSpeed: Float = 1.0
|
|
21
|
+
private var playbackType: PlaybackType = .streaming
|
|
21
22
|
|
|
22
23
|
private var playerItemBufferEmptyObserver: NSKeyValueObservation?
|
|
23
24
|
private var playerItemBufferKeepUpObserver: NSKeyValueObservation?
|
|
@@ -73,16 +74,25 @@ class VdoCipherRNView: UIView {
|
|
|
73
74
|
|
|
74
75
|
playerItemBufferEmptyObserver = self.player?.currentItem?.observe(\AVPlayerItem.isPlaybackBufferEmpty, options: [.new]) { [weak self] (_, _) in
|
|
75
76
|
guard let self = self else { return }
|
|
77
|
+
if self.playbackType == .offline || self.playerState == .buffering {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
76
80
|
self.playerState = .buffering
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
playerItemBufferKeepUpObserver = self.player?.currentItem?.observe(\AVPlayerItem.isPlaybackLikelyToKeepUp, options: [.new]) { [weak self] (_, _) in
|
|
80
84
|
guard let self = self else { return }
|
|
85
|
+
if self.playerState == .ready {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
81
88
|
self.playerState = .ready
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
playerItemBufferFullObserver = self.player?.currentItem?.observe(\AVPlayerItem.isPlaybackBufferFull, options: [.new]) { [weak self] (_, _) in
|
|
85
92
|
guard let self = self else { return }
|
|
93
|
+
if self.playerState == .ready {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
86
96
|
self.playerState = .ready
|
|
87
97
|
}
|
|
88
98
|
|
|
@@ -132,6 +142,66 @@ class VdoCipherRNView: UIView {
|
|
|
132
142
|
progressTimer = nil
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
func parseOfflineCredentials(fromInfo embedInfo: [String: Any]) {
|
|
146
|
+
guard let mediaId = embedInfo["mediaId"] as? String else {
|
|
147
|
+
let errorDescription = ErrorDescription(errorCode: 4101, errorMsg: "Error: 4101 Invalid video parameters. Please contact the app developer.", httpStatusCode: -1)
|
|
148
|
+
self.sendErrorEventWithDescription(errorDescription)
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
self.playbackType = .offline
|
|
152
|
+
self.initiatePlayback(withInfo: embedInfo, videoId: mediaId)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
func parseOnlineCredentials(fromInfo embedInfo: [String: Any]) {
|
|
156
|
+
guard let playbackInfo = embedInfo["playbackInfo"] as? String,
|
|
157
|
+
let otp = embedInfo["otp"] as? String,
|
|
158
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
159
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded) else {
|
|
160
|
+
let errorDescription = ErrorDescription(errorCode: 4101, errorMsg: "Error: 4101 Invalid video parameters. Please contact the app developer.", httpStatusCode: -1)
|
|
161
|
+
self.sendErrorEventWithDescription(errorDescription)
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
self.playbackType = .streaming
|
|
165
|
+
self.initiatePlayback(withInfo: embedInfo, videoId: parsed.videoId, onlineCredentials: Credentials(otp: otp, playbackInfo: playbackInfo))
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private func initiatePlayback(withInfo embedInfo: [String: Any], videoId: String, onlineCredentials: Credentials? = nil) {
|
|
169
|
+
let customPlayerId = embedInfo["customPlayerId"] as? String
|
|
170
|
+
let preferredCaptionsLanguage = embedInfo["preferredCaptionsLanguage"] as? String
|
|
171
|
+
let enableAutoResume = embedInfo["enableAutoResume"] as? Bool
|
|
172
|
+
if enableAutoResume == false {
|
|
173
|
+
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.VdoFramework")
|
|
174
|
+
if var assetsLastPlaybackTimeSet = userDefaults?.value(forKey: "assetsLastPlaybackTimeSet") as? [String: Double] {
|
|
175
|
+
assetsLastPlaybackTimeSet[videoId] = Double(0)
|
|
176
|
+
userDefaults?.set(assetsLastPlaybackTimeSet, forKey: "assetsLastPlaybackTimeSet")
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
VdoAsset.createAsset(videoId: videoId, playerId: customPlayerId, onLoad: { asset, err in
|
|
180
|
+
DispatchQueue.main.async {
|
|
181
|
+
guard let asset = asset else {
|
|
182
|
+
if let error = err {
|
|
183
|
+
let errorDescription = ErrorDescription(errorCode: error.code, errorMsg: error.message, httpStatusCode: -1)
|
|
184
|
+
self.sendErrorEventWithDescription(errorDescription)
|
|
185
|
+
}
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
self.asset = asset
|
|
189
|
+
TrackSelection.asset = asset
|
|
190
|
+
if preferredCaptionsLanguage?.isEmpty == false {
|
|
191
|
+
DispatchQueue.main.async {
|
|
192
|
+
_ = self.setCaptionLanguage(lanCode: preferredCaptionsLanguage)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if let onlineCredentials = onlineCredentials {
|
|
196
|
+
asset.playOnline(otp: onlineCredentials.otp, playbackInfo: onlineCredentials.playbackInfo)
|
|
197
|
+
} else {
|
|
198
|
+
asset.playOffline()
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
135
205
|
@objc func videoDidEnd(notification: NSNotification) {
|
|
136
206
|
if self.playerState == .ended {
|
|
137
207
|
return
|
|
@@ -255,7 +325,7 @@ extension VdoCipherRNView: AssetPlaybackDelegate {
|
|
|
255
325
|
|
|
256
326
|
guard let asset = asset else { return }
|
|
257
327
|
let mInfo = Media(mediaId: asset.videoId,
|
|
258
|
-
type:
|
|
328
|
+
type: playbackType.rawValue,
|
|
259
329
|
title: asset.title ?? "",
|
|
260
330
|
description: asset.description,
|
|
261
331
|
duration: (Int(asset.duration ?? 0.0) * 1000) )
|
|
@@ -303,10 +373,19 @@ extension VdoCipherRNView: UINavigationControllerDelegate {
|
|
|
303
373
|
}
|
|
304
374
|
}
|
|
305
375
|
|
|
306
|
-
private enum PlayerState : String
|
|
307
|
-
{
|
|
376
|
+
private enum PlayerState : String {
|
|
308
377
|
case buffering = "buffering",
|
|
309
378
|
ready = "ready",
|
|
310
379
|
ended = "ended",
|
|
311
380
|
unknown = "unknown"
|
|
312
381
|
}
|
|
382
|
+
|
|
383
|
+
fileprivate struct Credentials {
|
|
384
|
+
let otp: String
|
|
385
|
+
let playbackInfo: String
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
private enum PlaybackType: String {
|
|
389
|
+
case streaming
|
|
390
|
+
case offline
|
|
391
|
+
}
|
package/ios/VdoDownload.swift
CHANGED
|
@@ -9,31 +9,26 @@ import Foundation
|
|
|
9
9
|
import React
|
|
10
10
|
|
|
11
11
|
class DownloadEventEmitter {
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
/// Shared Instance.
|
|
14
14
|
public static var sharedInstance = DownloadEventEmitter()
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
// ReactNativeEventEmitter is instantiated by React Native with the bridge.
|
|
17
17
|
private static var eventEmitter: VdoDownload!
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
private init() {}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
// When React Native instantiates the emitter it is registered here.
|
|
22
22
|
func registerEventEmitter(eventEmitter: VdoDownload) {
|
|
23
23
|
DownloadEventEmitter.eventEmitter = eventEmitter
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
func dispatch(name: DownloadEventName, params: [String: Any]?) {
|
|
27
27
|
if DownloadEventEmitter.eventEmitter.hasListener == true {
|
|
28
|
-
|
|
29
|
-
if let p = params {
|
|
30
|
-
data["nativeEvent"] = p
|
|
31
|
-
}
|
|
32
|
-
// print("event data sent is \(data)")
|
|
33
|
-
DownloadEventEmitter.eventEmitter.sendEvent(withName: name.rawValue, body: data)
|
|
28
|
+
DownloadEventEmitter.eventEmitter.sendEvent(withName: name.rawValue, body: params)
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
|
-
|
|
31
|
+
|
|
37
32
|
/// All Events which must be support by React Native.
|
|
38
33
|
lazy var allEvents: [String] = {
|
|
39
34
|
|
|
@@ -50,13 +45,36 @@ enum DownloadEventName: String, CaseIterable {
|
|
|
50
45
|
case EVENT_DELETED = "onDeleted"
|
|
51
46
|
}
|
|
52
47
|
|
|
48
|
+
//enum DownloadStatusKeys: String {
|
|
49
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_MEDIA_INFO = "mediaInfo"
|
|
50
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_LOCAL_STORAGE_FOLDER = "localStorageFolder"
|
|
51
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_STATUS = "status"
|
|
52
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_REASON = "reason"
|
|
53
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_REASON_DESCRIPTION = "reasonDescription"
|
|
54
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_TOTAL_SIZE_BYTES = "totalSizeBytes"
|
|
55
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_BYTES_DOWNLOADED = "bytesDownloaded"
|
|
56
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_DOWNLOAD_PERCENT = "downloadPercent"
|
|
57
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_POSTER = "poster"
|
|
58
|
+
// case EVENT_PROP_DOWNLOAD_STATUS_LAST_MODIFIED_TIMESTAMP = "lastModifiedTimestamp"
|
|
59
|
+
//}
|
|
60
|
+
|
|
53
61
|
@objc(VdoDownload)
|
|
54
62
|
class VdoDownload: RCTEventEmitter {
|
|
55
63
|
|
|
64
|
+
var asset: VdoAsset?
|
|
65
|
+
var availableTracksMap: [[String: Any]]?
|
|
66
|
+
var optionParams: [String: Any]?
|
|
67
|
+
|
|
68
|
+
// MARK: RCTEventEmitter functions
|
|
56
69
|
override init() {
|
|
57
70
|
super.init()
|
|
58
|
-
// print("\(type(of: self))).\(#function)")
|
|
59
71
|
DownloadEventEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
|
|
72
|
+
self.addDownloadObservers()
|
|
73
|
+
VdoCipher.logLevel = .info
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
deinit {
|
|
77
|
+
self.removeObservers()
|
|
60
78
|
}
|
|
61
79
|
|
|
62
80
|
var hasListener: Bool?
|
|
@@ -65,39 +83,371 @@ class VdoDownload: RCTEventEmitter {
|
|
|
65
83
|
///
|
|
66
84
|
/// - Returns: all supported events
|
|
67
85
|
@objc open override func supportedEvents() -> [String] {
|
|
68
|
-
// print("\(type(of: self))).\(#function)")
|
|
69
86
|
return DownloadEventEmitter.sharedInstance.allEvents
|
|
70
87
|
}
|
|
71
88
|
|
|
72
89
|
@objc open override func startObserving() {
|
|
73
90
|
super.startObserving()
|
|
74
91
|
hasListener = true
|
|
75
|
-
// print("\(type(of: self))).\(#function)")
|
|
76
92
|
}
|
|
77
|
-
|
|
93
|
+
|
|
78
94
|
@objc open override func stopObserving() {
|
|
79
95
|
super.stopObserving()
|
|
80
96
|
hasListener = false
|
|
81
|
-
// print("\(type(of: self))).\(#function)")
|
|
82
97
|
}
|
|
83
98
|
|
|
84
99
|
open override class func requiresMainQueueSetup() -> Bool {
|
|
85
|
-
// print("\(type(of: self))).\(#function)")
|
|
86
100
|
return true
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
open override func addListener(_ eventName: String!) {
|
|
90
104
|
super.addListener(eventName)
|
|
91
|
-
// print("\(type(of: self))).\(#function) eventName: \(eventName)")
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
open override func removeListeners(_ count: Double) {
|
|
95
108
|
super.removeListeners(count)
|
|
96
|
-
// print("\(type(of: self))).\(#function) count: \(count)")
|
|
97
109
|
}
|
|
98
|
-
|
|
110
|
+
|
|
99
111
|
open override func invalidate() {
|
|
100
112
|
super.invalidate()
|
|
101
|
-
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// MARK: Download functionality
|
|
116
|
+
@objc func query(_ queryFilters: [String: Any], errorCallback: RCTResponseSenderBlock, successCallback: RCTResponseSenderBlock) {
|
|
117
|
+
let mediaIdsRaw = queryFilters["mediaId"] as? [String]
|
|
118
|
+
let statusNames = queryFilters["status"] as? [String]
|
|
119
|
+
var mediaIds : [String] = []
|
|
120
|
+
if let mediaIdsRaw = mediaIdsRaw {
|
|
121
|
+
mediaIds = mediaIdsRaw
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let downloadStates: [VdoAsset.DownloadState] = getDownloadStateList(downloadStatesRaw: statusNames)
|
|
125
|
+
|
|
126
|
+
let downloadFilter : DownloadInfoFilter
|
|
127
|
+
if downloadStates.count != 0 {
|
|
128
|
+
downloadFilter = DownloadInfoFilter (videoId: mediaIds.count != 0 ? mediaIds : nil, downloadState: downloadStates)
|
|
129
|
+
}
|
|
130
|
+
else{
|
|
131
|
+
downloadFilter = DownloadInfoFilter (videoId: mediaIds.count != 0 ? mediaIds : nil)
|
|
132
|
+
}
|
|
133
|
+
let downloadedAssests = VdoCipher.getListOfDownloads(filterBy: downloadFilter).map { self.createOfflineVdoAssetMap(with: $0) }
|
|
134
|
+
successCallback([downloadedAssests])
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private func getDownloadStateList(downloadStatesRaw : [String]?) -> [VdoAsset.DownloadState]{
|
|
138
|
+
var downloadStates : [VdoAsset.DownloadState] = []
|
|
139
|
+
if let downloadStatesRaw = downloadStatesRaw {
|
|
140
|
+
for downloadState in downloadStatesRaw {
|
|
141
|
+
switch(downloadState){
|
|
142
|
+
case "completed":
|
|
143
|
+
downloadStates.append(.downloaded)
|
|
144
|
+
break;
|
|
145
|
+
case "pending":
|
|
146
|
+
downloadStates.append(.notDownloaded)
|
|
147
|
+
break;
|
|
148
|
+
case "paused":
|
|
149
|
+
downloadStates.append(.paused)
|
|
150
|
+
break;
|
|
151
|
+
case "downloading":
|
|
152
|
+
downloadStates.append(.downloading)
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return downloadStates
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@objc func getDownloadOptions(_ optionParams: [String: Any], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock) {
|
|
163
|
+
guard let playbackInfo = optionParams["playbackInfo"] as? String,
|
|
164
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
165
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded),
|
|
166
|
+
let _ = optionParams["otp"] as? String else {
|
|
167
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
168
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "PlaybackInfo or OTP not found"]])
|
|
169
|
+
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
VdoAsset.createAsset(videoId: parsed.videoId, onLoad: { asset, err in
|
|
173
|
+
guard let asset = asset else {
|
|
174
|
+
if let error = err {
|
|
175
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: error.code,
|
|
176
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: error.message] as [String : Any]])
|
|
177
|
+
} else {
|
|
178
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
179
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Unknown error occured"]])
|
|
180
|
+
}
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
let qualities = asset.getVideoQualities()
|
|
184
|
+
if qualities.count == 0 {
|
|
185
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
186
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Tracks Not Found"]])
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
let availableTracks = self.createTracksMap(with: qualities)
|
|
190
|
+
self.availableTracksMap = availableTracks
|
|
191
|
+
self.asset = asset
|
|
192
|
+
self.optionParams = optionParams
|
|
193
|
+
let mediaInfo = self.createMediaInfoMap(with: asset)
|
|
194
|
+
let downloadOptions = self.createDownloadOptionsMap(with: availableTracks, mediaInfo: mediaInfo)
|
|
195
|
+
let downloadOptionsMap = [playbackInfo, downloadOptions] as [Any]
|
|
196
|
+
successCallback(downloadOptionsMap)
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@objc func enqueueDownload(_ nativeId: String, requestOptions: [String: Any], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock) {
|
|
201
|
+
guard let optionParams = optionParams, let otp = optionParams["otp"] as? String, let playbackInfo = optionParams["playbackInfo"] as? String else {
|
|
202
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
203
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "PlaybackInfo or OTP not found"]])
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
if nativeId != playbackInfo {
|
|
207
|
+
// This is to overcome a condition if last 'getDownloadOptions' api was called for a different mediaId. Since, otp is passed with 'getDownloadOptions' and not with 'enqueue' we need to rely on 'getDownloadOptions'. Also, ReactNative apis are designed in a way that 'enqueue' func is returned on calling 'getDownloadOptions' but 'enqueue' cannot be called indvidually.
|
|
208
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
209
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Call getDownloadOptions before calling enqueue"]])
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
guard let asset = asset else {
|
|
213
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
214
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Unknown error occured"]])
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
if let selections = requestOptions["selections"] as? [Int],
|
|
218
|
+
let index = selections.first,
|
|
219
|
+
asset.getVideoQualities().count > index {
|
|
220
|
+
// assuming index from 'availableTracksMap' is equivalent to index of 'asset.getVideoQualities()' as both are ordered pairs
|
|
221
|
+
asset.startDownload(otp: otp, playbackInfo: playbackInfo, videoQuality: asset.getVideoQualities()[index])
|
|
222
|
+
asset.percentDownload = 0
|
|
223
|
+
successCallback([])
|
|
224
|
+
} else {
|
|
225
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
226
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Invalid selection"]])
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@objc func stop(_ mediaIds: [String], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock) {
|
|
231
|
+
for mediaId in mediaIds {
|
|
232
|
+
VdoAsset.createAsset(videoId: mediaId) { asset, error in
|
|
233
|
+
if let asset = asset {
|
|
234
|
+
asset.pauseDownload()
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
successCallback([])
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@objc func resume(_ mediaIds: [String], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock) {
|
|
242
|
+
for mediaId in mediaIds {
|
|
243
|
+
VdoAsset.createAsset(videoId: mediaId) { asset, error in
|
|
244
|
+
if let asset = asset {
|
|
245
|
+
asset.resumeDownload()
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
successCallback([])
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
@objc func remove(_ mediaIds: [String], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock ) {
|
|
254
|
+
for mediaId in mediaIds {
|
|
255
|
+
VdoAsset.createAsset(videoId: mediaId) { asset, error in
|
|
256
|
+
if let asset = asset {
|
|
257
|
+
if asset.downloadState == .downloading || asset.downloadState == .paused {
|
|
258
|
+
asset.cancelDownload()
|
|
259
|
+
}
|
|
260
|
+
else if asset.downloadState == .downloaded {
|
|
261
|
+
asset.deleteDownload()
|
|
262
|
+
}
|
|
263
|
+
asset.percentDownload = 0
|
|
264
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_DELETED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
successCallback([])
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// MARK: Add-Remove Observer functions
|
|
272
|
+
private func addDownloadObservers() {
|
|
273
|
+
NotificationCenter.default.addObserver(self, selector: #selector(handleDownloadProgress(_:)), name: .AssetDownloadProgress, object: nil)
|
|
274
|
+
NotificationCenter.default.addObserver(self, selector: #selector(handleDownloadStateChange(_:)), name: .AssetDownloadStateChanged, object: nil)
|
|
275
|
+
NotificationCenter.default.addObserver(self, selector: #selector(handleDownloadFailed(_:)), name: .AssetDownloadFailed, object: nil)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private func removeObservers() {
|
|
279
|
+
NotificationCenter.default.removeObserver(self, name: .AssetDownloadProgress, object: nil)
|
|
280
|
+
NotificationCenter.default.removeObserver(self, name: .AssetDownloadStateChanged, object: nil)
|
|
281
|
+
NotificationCenter.default.removeObserver(self, name: .AssetDownloadFailed, object: nil)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// MARK: Notification handlers
|
|
285
|
+
@objc func handleDownloadStateChange(_ notification: Notification) {
|
|
286
|
+
let notice = notification.userInfo!
|
|
287
|
+
guard let stateRawValue = notice[VdoAsset.Keys.downloadState] as? String,
|
|
288
|
+
let newState = VdoAsset.DownloadState(rawValue: (stateRawValue)) else {
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
if newState == .notDownloaded {
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
if let videoId = notice[VdoAsset.Keys.videoId] as? String {
|
|
295
|
+
if videoId == self.asset?.videoId, let asset = asset {
|
|
296
|
+
if newState == .downloaded {
|
|
297
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_COMPLETED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
298
|
+
} else if newState == .downloading {
|
|
299
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_QUEUED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
300
|
+
} else {
|
|
301
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_CHANGED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
VdoAsset.createAsset(videoId: videoId) { asset, _ in
|
|
305
|
+
guard let asset = asset else { return }
|
|
306
|
+
if newState == .downloaded {
|
|
307
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_COMPLETED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
308
|
+
} else if newState == .downloading {
|
|
309
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_QUEUED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
310
|
+
} else {
|
|
311
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_CHANGED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@objc func handleDownloadProgress(_ notification: Notification) {
|
|
319
|
+
let notice = notification.userInfo!
|
|
320
|
+
guard let percentDownload = notice[VdoAsset.Keys.percentDownloaded] as? Double else {
|
|
321
|
+
return
|
|
322
|
+
}
|
|
323
|
+
if let videoId = notice[VdoAsset.Keys.videoId] as? String {
|
|
324
|
+
if videoId == self.asset?.videoId, let asset = asset {
|
|
325
|
+
asset.percentDownload = percentDownload
|
|
326
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_CHANGED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
327
|
+
} else {
|
|
328
|
+
VdoAsset.createAsset(videoId: videoId) { asset, _ in
|
|
329
|
+
guard let asset = asset else { return }
|
|
330
|
+
asset.percentDownload = percentDownload
|
|
331
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_CHANGED, params: ["mediaId": asset.videoId, "downloadStatus": self.createVdoAssetMap(with: asset)])
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
@objc func handleDownloadFailed(_ notification: Notification) {
|
|
338
|
+
let notice = notification.userInfo!
|
|
339
|
+
guard let message = notice[VdoAsset.Keys.message] as? String, let code = notice[VdoAsset.Keys.code] else {return}
|
|
340
|
+
if let videoId = notice[VdoAsset.Keys.videoId] as? String {
|
|
341
|
+
if videoId == self.asset?.videoId, let asset = asset {
|
|
342
|
+
var assetMap = self.createVdoAssetMap(with: asset)
|
|
343
|
+
assetMap["reasonDescription"] = message
|
|
344
|
+
assetMap["reason"] = code
|
|
345
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_FAILED, params: ["mediaId": asset.videoId, "downloadStatus": assetMap])
|
|
346
|
+
} else {
|
|
347
|
+
VdoAsset.createAsset(videoId: videoId) { asset, _ in
|
|
348
|
+
guard let asset = asset else { return }
|
|
349
|
+
var assetMap = self.createVdoAssetMap(with: asset)
|
|
350
|
+
assetMap["reasonDescription"] = message
|
|
351
|
+
assetMap["reason"] = code
|
|
352
|
+
DownloadEventEmitter.sharedInstance.dispatch(name: .EVENT_FAILED, params: ["mediaId": asset.videoId, "downloadStatus": assetMap])
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// MARK: Map creation functions
|
|
359
|
+
private func createTracksMap(with videoQualities: [VdoFramework.VdoAsset.VideoQuality]) -> [[String: Any]] {
|
|
360
|
+
var tracks: [[String: Any]] = []
|
|
361
|
+
var counter = 1
|
|
362
|
+
for quality in videoQualities {
|
|
363
|
+
var track: [String: Any] = [:]
|
|
364
|
+
track["id"] = counter
|
|
365
|
+
track["type"] = "video"
|
|
366
|
+
track["bitrate"] = quality.bitrate
|
|
367
|
+
let resolution = quality.resolution.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
368
|
+
let size = resolution.components(separatedBy: "x")
|
|
369
|
+
if size.count == 2 {
|
|
370
|
+
track["width"] = Int(size.first ?? "") ?? 0
|
|
371
|
+
track["height"] = Int(size.last ?? "") ?? 0
|
|
372
|
+
}
|
|
373
|
+
counter += 1
|
|
374
|
+
tracks.append(track)
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return tracks
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
private func createDownloadOptionsMap(with availableTracks: [[String: Any]], mediaInfo: [String: Any]) -> [String: Any] {
|
|
381
|
+
var downloadOptionsMap: [String: Any] = [:]
|
|
382
|
+
downloadOptionsMap["mediaId"] = mediaInfo["mediaId"]
|
|
383
|
+
downloadOptionsMap["mediaInfo"] = mediaInfo
|
|
384
|
+
downloadOptionsMap["availableTracks"] = availableTracks
|
|
385
|
+
return downloadOptionsMap
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
private func createMediaInfoMap(with mediaInfo: MediaInfo) -> [String: Any] {
|
|
389
|
+
var mediaInfoMap : [String: Any] = [:]
|
|
390
|
+
|
|
391
|
+
mediaInfoMap["title"] = mediaInfo.title
|
|
392
|
+
mediaInfoMap["duration"] = Int(mediaInfo.duration ) * 1000
|
|
393
|
+
mediaInfoMap["mediaId"] = mediaInfo.videoId
|
|
394
|
+
mediaInfoMap["description"] = mediaInfo.mediaDescription
|
|
395
|
+
mediaInfoMap["type"] = "info"
|
|
396
|
+
|
|
397
|
+
return mediaInfoMap
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private func createMediaInfoMap(with asset: VdoAsset) -> [String: Any] {
|
|
401
|
+
var mediaInfoMap : [String: Any] = [:]
|
|
402
|
+
|
|
403
|
+
mediaInfoMap["title"] = asset.title
|
|
404
|
+
mediaInfoMap["duration"] = Int(asset.duration ?? 0) * 1000
|
|
405
|
+
mediaInfoMap["mediaId"] = asset.videoId
|
|
406
|
+
mediaInfoMap["description"] = asset.description
|
|
407
|
+
mediaInfoMap["type"] = "info"
|
|
408
|
+
|
|
409
|
+
return mediaInfoMap
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
private func createVdoAssetMap(with asset: VdoAsset) -> [String: Any] {
|
|
413
|
+
var downloadStatus: [String: Any] = [:]
|
|
414
|
+
|
|
415
|
+
downloadStatus["mediaInfo"] = createMediaInfoMap(with: asset)
|
|
416
|
+
downloadStatus["downloadPercent"] = Int(asset.percentDownload * 100)
|
|
417
|
+
downloadStatus["status"] = self.mapDownloadStateToRNText(downloadState: asset.downloadState)
|
|
418
|
+
downloadStatus["aspectRatio"] = asset.aspectRatio
|
|
419
|
+
if (asset.posters?.isEmpty == false) {
|
|
420
|
+
downloadStatus["poster"] = asset.posters?[0].url ?? ""
|
|
421
|
+
}
|
|
422
|
+
else{
|
|
423
|
+
downloadStatus["poster"] = ""
|
|
424
|
+
}
|
|
425
|
+
return downloadStatus
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
private func createOfflineVdoAssetMap(with downloadInfo: DownloadInfo) -> [String: Any] {
|
|
429
|
+
var downloadStatus: [String: Any] = [:]
|
|
430
|
+
|
|
431
|
+
downloadStatus["mediaInfo"] = createMediaInfoMap(with: downloadInfo.mediaInfo)
|
|
432
|
+
downloadStatus["downloadPercent"] = Int(downloadInfo.percentDownloaded * 100)
|
|
433
|
+
downloadStatus["status"] = self.mapDownloadStateToRNText(downloadState: downloadInfo.status)
|
|
434
|
+
downloadStatus["aspectRatio"] = downloadInfo.aspectRatio
|
|
435
|
+
downloadStatus["poster"] = downloadInfo.poster
|
|
436
|
+
return downloadStatus
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private func mapDownloadStateToRNText(downloadState: VdoAsset.DownloadState) -> String {
|
|
440
|
+
switch downloadState {
|
|
441
|
+
case .downloaded:
|
|
442
|
+
return "completed"
|
|
443
|
+
case.downloading:
|
|
444
|
+
return "downloading"
|
|
445
|
+
case .notDownloaded:
|
|
446
|
+
return "pending"
|
|
447
|
+
case .paused:
|
|
448
|
+
return "paused"
|
|
449
|
+
@unknown default:
|
|
450
|
+
return "pending"
|
|
451
|
+
}
|
|
102
452
|
}
|
|
103
453
|
}
|
|
@@ -66,7 +66,12 @@ RCT_EXTERN_METHOD(supportedEvents)
|
|
|
66
66
|
@interface RCT_EXTERN_MODULE(VdoDownload, RCTEventEmitter)
|
|
67
67
|
|
|
68
68
|
RCT_EXTERN_METHOD(supportedEvents)
|
|
69
|
-
|
|
69
|
+
RCT_EXTERN_METHOD(query: (NSDictionary *) queryFilters errorCallback: (RCTResponseSenderBlock) errorCallback successCallback: (RCTResponseSenderBlock) successCallback)
|
|
70
|
+
RCT_EXTERN_METHOD(getDownloadOptions: (NSDictionary *) optionParams errorCallback: (RCTResponseSenderBlock) errorCallback successCallback: (RCTResponseSenderBlock) successCallback)
|
|
71
|
+
RCT_EXTERN_METHOD(enqueueDownload: (NSString *) nativeId requestOptions: (NSDictionary *) requestOptions errorCallback: (RCTResponseSenderBlock) errorCallback successCallback: (RCTResponseSenderBlock) successCallback)
|
|
72
|
+
RCT_EXTERN_METHOD(remove: (NSArray *) mediaIds errorCallback: (RCTResponseSenderBlock) errorCallback successCallback: (RCTResponseSenderBlock) successCallback)
|
|
73
|
+
RCT_EXTERN_METHOD(stop: (NSArray *) mediaId errorCallback: (RCTResponseSenderBlock) errorCallback successCallback: (RCTResponseSenderBlock) successCallback)
|
|
74
|
+
RCT_EXTERN_METHOD(resume: (NSArray *) mediaId errorCallback: (RCTResponseSenderBlock) errorCallback successCallback: (RCTResponseSenderBlock) successCallback)
|
|
70
75
|
@end
|
|
71
76
|
|
|
72
77
|
@interface RCT_EXTERN_MODULE(VdoPlayer, NSObject)
|
|
@@ -97,3 +102,5 @@ RCT_EXTERN_METHOD(getDuration: (RCTResponseSenderBlock) callback)
|
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
@end
|
|
105
|
+
|
|
106
|
+
|
|
@@ -5,7 +5,7 @@ import VdoFramework
|
|
|
5
5
|
@objc(VdocipherRnBridge)
|
|
6
6
|
class VdocipherRnBridge: RCTViewManager {
|
|
7
7
|
|
|
8
|
-
static let vdocipherRnBridgeVersionString = "1.17.
|
|
8
|
+
static let vdocipherRnBridgeVersionString = "1.17.1"
|
|
9
9
|
|
|
10
10
|
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
11
11
|
return true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdocipher-rn-bridge",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"description": "React native bridge library that delegates to vdocipher native android SDK",
|
|
5
5
|
"homepage": "https://www.vdocipher.com/docs/mobile/react-native/getting-started/",
|
|
6
6
|
"scripts": {
|