vdocipher-rn-bridge 1.19.2 → 1.20.0
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/build.gradle +3 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +17 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +17 -3
- package/android/src/main/java/com/vdocipher/rnbridge/VdoDownloadModule.java +45 -20
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +17 -3
- package/ios/RCTVdoPlayerUIView.swift +58 -17
- package/ios/VdoCipherRNView.swift +67 -29
- package/ios/VdoDownload.swift +79 -28
- package/ios/VdocipherRnBridgeViewManager.swift +32 -9
- package/package.json +1 -1
- package/react-native-vdocipher-rn-bridge.podspec +1 -1
- package/type.ts +56 -1
- package/ios/Podfile.lock +0 -3
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.
|
|
22
|
-
def releaseVersionCode =
|
|
21
|
+
def releaseVersionName = "1.20.0"
|
|
22
|
+
def releaseVersionCode = 32
|
|
23
23
|
|
|
24
24
|
android {
|
|
25
25
|
compileSdkVersion 33
|
|
@@ -86,5 +86,5 @@ repositories {
|
|
|
86
86
|
dependencies {
|
|
87
87
|
compileOnly 'com.facebook.react:react-native:+'
|
|
88
88
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
|
89
|
-
implementation 'com.vdocipher.aegis:vdocipher-android:1.26.
|
|
89
|
+
implementation 'com.vdocipher.aegis:vdocipher-android:1.26.1'
|
|
90
90
|
}
|
|
@@ -70,6 +70,8 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
70
70
|
embedInfo.getString("preferredCaptionsLanguage") : null;
|
|
71
71
|
boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
|
|
72
72
|
embedInfo.getBoolean("allowAdbDebugging");
|
|
73
|
+
int resumeTimeMs = embedInfo.hasKey("resumeTimeMs") ?
|
|
74
|
+
embedInfo.getInt("resumeTimeMs") : 0;
|
|
73
75
|
|
|
74
76
|
VdoInitParams.Builder builder = new VdoInitParams.Builder();
|
|
75
77
|
|
|
@@ -80,6 +82,10 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
80
82
|
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
if (resumeTimeMs > 0) {
|
|
86
|
+
builder.setResumeTime(resumeTimeMs);
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
if (offline) {
|
|
84
90
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
85
91
|
|
|
@@ -89,6 +95,8 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
89
95
|
} else {
|
|
90
96
|
String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
|
|
91
97
|
String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
|
|
98
|
+
String token = embedInfo.hasKey("token") ? embedInfo.getString("token") : null;
|
|
99
|
+
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
92
100
|
boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
|
|
93
101
|
&& embedInfo.getBoolean("forceLowestBitrate");
|
|
94
102
|
boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
|
|
@@ -105,9 +113,15 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
105
113
|
customPlayerId = embedInfo.getString("playerConfig");
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
|
|
116
|
+
if (token != null && mediaId != null) {
|
|
117
|
+
builder.setToken(token)
|
|
118
|
+
.setVideoId(mediaId);
|
|
119
|
+
} else if (otp != null && playbackInfo != null) {
|
|
120
|
+
builder.setOtp(otp)
|
|
121
|
+
.setPlaybackInfo(playbackInfo);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
builder.setAllowAdbDebugging(allowAdbDebugging)
|
|
111
125
|
.setForceLowestBitrate(forceLowestBitrate)
|
|
112
126
|
.setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
|
|
113
127
|
.setMaxVideoBitrateKbps(maxVideoBitrateKbps);
|
|
@@ -71,6 +71,8 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
71
71
|
embedInfo.getString("preferredCaptionsLanguage") : null;
|
|
72
72
|
boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
|
|
73
73
|
embedInfo.getBoolean("allowAdbDebugging");
|
|
74
|
+
int resumeTimeMs = embedInfo.hasKey("resumeTimeMs") ?
|
|
75
|
+
embedInfo.getInt("resumeTimeMs") : 0;
|
|
74
76
|
|
|
75
77
|
VdoInitParams.Builder builder = new VdoInitParams.Builder();
|
|
76
78
|
|
|
@@ -81,6 +83,10 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
81
83
|
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
if (resumeTimeMs > 0) {
|
|
87
|
+
builder.setResumeTime(resumeTimeMs);
|
|
88
|
+
}
|
|
89
|
+
|
|
84
90
|
if (offline) {
|
|
85
91
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
86
92
|
|
|
@@ -90,6 +96,8 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
90
96
|
} else {
|
|
91
97
|
String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
|
|
92
98
|
String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
|
|
99
|
+
String token = embedInfo.hasKey("token") ? embedInfo.getString("token") : null;
|
|
100
|
+
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
93
101
|
boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
|
|
94
102
|
&& embedInfo.getBoolean("forceLowestBitrate");
|
|
95
103
|
boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
|
|
@@ -100,9 +108,15 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
100
108
|
embedInfo.getInt("bufferingGoalMs") : 0;
|
|
101
109
|
String[] overrides = getTechOverride(embedInfo);
|
|
102
110
|
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
111
|
+
if (token != null && mediaId != null) {
|
|
112
|
+
builder.setToken(token)
|
|
113
|
+
.setVideoId(mediaId);
|
|
114
|
+
} else if (otp != null && playbackInfo != null) {
|
|
115
|
+
builder.setOtp(otp)
|
|
116
|
+
.setPlaybackInfo(playbackInfo);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
builder.setAllowAdbDebugging(allowAdbDebugging)
|
|
106
120
|
.setForceLowestBitrate(forceLowestBitrate)
|
|
107
121
|
.setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
|
|
108
122
|
.setMaxVideoBitrateKbps(maxVideoBitrateKbps);
|
|
@@ -80,6 +80,8 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
80
80
|
}
|
|
81
81
|
String otp = optionParams.getString("otp");
|
|
82
82
|
String playbackInfo = optionParams.getString("playbackInfo");
|
|
83
|
+
String token = optionParams.getString("token");
|
|
84
|
+
String mediaId = optionParams.getString("mediaId");
|
|
83
85
|
String customPlayerId = null;
|
|
84
86
|
if (optionParams.getString("customPlayerId") != null) {
|
|
85
87
|
customPlayerId = optionParams.getString("customPlayerId");
|
|
@@ -89,26 +91,49 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
89
91
|
OptionsDownloader optionsDownloader = new OptionsDownloader(getReactApplicationContext());
|
|
90
92
|
|
|
91
93
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
94
|
+
if (token != null && mediaId != null) {
|
|
95
|
+
optionsDownloader.downloadOptionsWithToken(token, mediaId, customPlayerId, new OptionsDownloader.Callback() {
|
|
96
|
+
@Override
|
|
97
|
+
public void onOptionsReceived(DownloadOptions options) {
|
|
98
|
+
Log.i(TAG, "onOptionsReceived with token");
|
|
99
|
+
downloadOptionsStore.put(mediaId, options);
|
|
100
|
+
successCallback.invoke(
|
|
101
|
+
mediaId, /* nativeId */
|
|
102
|
+
makeDownloadOptionsMap(options)
|
|
103
|
+
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Override
|
|
108
|
+
public void onOptionsNotReceived(ErrorDescription errorDescription) {
|
|
109
|
+
Log.e(TAG, "onOptionsNotReceived with token: " + errorDescription.toString());
|
|
110
|
+
errorCallback.invoke(
|
|
111
|
+
makeErrorDescriptionMap(errorDescription)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
} else if (otp != null && playbackInfo != null) {
|
|
116
|
+
optionsDownloader.downloadOptionsWithOtp(otp, playbackInfo, customPlayerId, new OptionsDownloader.Callback() {
|
|
117
|
+
@Override
|
|
118
|
+
public void onOptionsReceived(DownloadOptions options) {
|
|
119
|
+
Log.i(TAG, "onOptionsReceived with otp");
|
|
120
|
+
downloadOptionsStore.put(playbackInfo, options);
|
|
121
|
+
successCallback.invoke(
|
|
122
|
+
playbackInfo, /* nativeId */
|
|
123
|
+
makeDownloadOptionsMap(options)
|
|
124
|
+
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Override
|
|
129
|
+
public void onOptionsNotReceived(ErrorDescription errorDescription) {
|
|
130
|
+
Log.e(TAG, "onOptionsNotReceived with otp: " + errorDescription.toString());
|
|
131
|
+
errorCallback.invoke(
|
|
132
|
+
makeErrorDescriptionMap(errorDescription)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
112
137
|
} catch (RuntimeException e) {
|
|
113
138
|
Log.e(TAG, Log.getStackTraceString(e));
|
|
114
139
|
ErrorDescription errDesc = new ErrorDescription(
|
|
@@ -46,6 +46,8 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
46
46
|
embedInfo.getString("preferredCaptionsLanguage") : null;
|
|
47
47
|
boolean allowAdbDebugging = !embedInfo.hasKey("allowAdbDebugging") ||
|
|
48
48
|
embedInfo.getBoolean("allowAdbDebugging");
|
|
49
|
+
int resumeTimeMs = embedInfo.hasKey("resumeTimeMs") ?
|
|
50
|
+
embedInfo.getInt("resumeTimeMs") : 0;
|
|
49
51
|
|
|
50
52
|
VdoInitParams.Builder builder = new VdoInitParams.Builder();
|
|
51
53
|
|
|
@@ -56,6 +58,10 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
56
58
|
builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
if (resumeTimeMs > 0) {
|
|
62
|
+
builder.setResumeTime(resumeTimeMs);
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
if (offline) {
|
|
60
66
|
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
61
67
|
|
|
@@ -65,6 +71,8 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
65
71
|
} else {
|
|
66
72
|
String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
|
|
67
73
|
String playbackInfo = embedInfo.hasKey("playbackInfo") ? embedInfo.getString("playbackInfo") : null;
|
|
74
|
+
String token = embedInfo.hasKey("token") ? embedInfo.getString("token") : null;
|
|
75
|
+
String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
|
|
68
76
|
boolean forceLowestBitrate = embedInfo.hasKey("forceLowestBitrate")
|
|
69
77
|
&& embedInfo.getBoolean("forceLowestBitrate");
|
|
70
78
|
boolean forceHighestSupportedBitrate = embedInfo.hasKey("forceHighestSupportedBitrate")
|
|
@@ -81,9 +89,15 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
|
|
|
81
89
|
customPlayerId = embedInfo.getString("playerConfig");
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
if (token != null && mediaId != null) {
|
|
93
|
+
builder.setToken(token)
|
|
94
|
+
.setVideoId(mediaId);
|
|
95
|
+
} else if (otp != null && playbackInfo != null) {
|
|
96
|
+
builder.setOtp(otp)
|
|
97
|
+
.setPlaybackInfo(playbackInfo);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
builder.setAllowAdbDebugging(allowAdbDebugging)
|
|
87
101
|
.setForceLowestBitrate(forceLowestBitrate)
|
|
88
102
|
.setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
|
|
89
103
|
.setMaxVideoBitrateKbps(maxVideoBitrateKbps);
|
|
@@ -7,35 +7,76 @@
|
|
|
7
7
|
|
|
8
8
|
import React
|
|
9
9
|
import Foundation
|
|
10
|
+
import AVKit
|
|
10
11
|
import VdoFramework
|
|
11
12
|
|
|
12
13
|
@objc(RCTVdoPlayerUIView)
|
|
13
14
|
class RCTVdoPlayerUIView: VdoCipherRNView {
|
|
14
15
|
|
|
16
|
+
var activityView: UIActivityIndicatorView?
|
|
17
|
+
|
|
15
18
|
override func setEmbedInfo(_ embedInfo: [String: Any]) {
|
|
16
19
|
super.setEmbedInfo(embedInfo)
|
|
17
20
|
|
|
21
|
+
EventEmitter.sharedInstance.dispatch(name: EventName.EVENT_LOADING, params: nil)
|
|
22
|
+
if embedInfo["offline"] as? Bool == true {
|
|
23
|
+
self.parseOfflineCredentials(fromInfo: embedInfo)
|
|
24
|
+
} else {
|
|
25
|
+
self.parseOnlineCredentials(fromInfo: embedInfo)
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33 , execute: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let playerViewController = VdoCipher.getVdoPlayerViewController()
|
|
23
|
-
playerViewController.view.frame = self.bounds
|
|
24
|
-
playerViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
25
|
-
guard let reactVC = self.reactViewController() else {
|
|
26
|
-
let errorDescription = ErrorDescription(errorCode: 3100, errorMsg: "Error: 3100 Failed to Load reactViewController. Please try again.", httpStatusCode: -1)
|
|
27
|
-
self.sendErrorEventWithDescription(errorDescription)
|
|
28
|
-
return
|
|
29
|
+
if self.playerState == .unknown {
|
|
30
|
+
self.showActivityIndicator()
|
|
29
31
|
}
|
|
30
|
-
reactVC.
|
|
31
|
-
self.addSubview(playerViewController.view)
|
|
32
|
-
playerViewController.didMove(toParent: reactVC)
|
|
32
|
+
guard let reactVC = self.reactViewController() else {return}
|
|
33
33
|
reactVC.navigationController?.delegate = self
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override func setUpPlayer(_ player: AVPlayer) {
|
|
38
|
+
let playerViewController = VdoCipher.getVdoPlayerViewController()
|
|
39
|
+
playerViewController.view.frame = self.bounds
|
|
40
|
+
playerViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
41
|
+
guard let reactVC = self.reactViewController() else {
|
|
42
|
+
let errorDescription = ErrorDescription(errorCode: 3100, errorMsg: "Error: 3100 Failed to Load reactViewController. Please try again.", httpStatusCode: -1)
|
|
43
|
+
self.sendErrorEventWithDescription(errorDescription)
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
reactVC.addChild(playerViewController)
|
|
47
|
+
self.addSubview(playerViewController.view)
|
|
48
|
+
playerViewController.didMove(toParent: reactVC)
|
|
49
|
+
playerViewController.view.isHidden = true
|
|
50
|
+
super.setUpPlayer(player)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override func playerReadyToPlay() {
|
|
54
|
+
self.hideActivityIndicator()
|
|
55
|
+
VdoCipher.getVdoPlayerViewController().view.isHidden = false
|
|
56
|
+
super.playerReadyToPlay()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
func showActivityIndicator() {
|
|
60
|
+
guard let reactVC = self.reactViewController() else {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
if activityView == nil {
|
|
64
|
+
if #available(iOS 13.0, *) {
|
|
65
|
+
activityView = UIActivityIndicatorView(style: .large)
|
|
36
66
|
} else {
|
|
37
|
-
|
|
67
|
+
activityView = UIActivityIndicatorView(style: .gray)
|
|
38
68
|
}
|
|
39
|
-
}
|
|
69
|
+
}
|
|
70
|
+
activityView?.center = self.center
|
|
71
|
+
reactVC.view.addSubview(activityView!)
|
|
72
|
+
activityView?.startAnimating()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
func hideActivityIndicator(){
|
|
76
|
+
if (activityView != nil){
|
|
77
|
+
activityView?.removeFromSuperview()
|
|
78
|
+
activityView?.stopAnimating()
|
|
79
|
+
activityView = nil
|
|
80
|
+
}
|
|
40
81
|
}
|
|
41
82
|
}
|
|
@@ -20,13 +20,14 @@ class VdoCipherRNView: UIView {
|
|
|
20
20
|
private var isLoaded = false
|
|
21
21
|
private var targetPlaybackSpeed: Float = 1.0
|
|
22
22
|
private var playbackType: PlaybackType = .streaming
|
|
23
|
+
private var resumeTime: CMTime?
|
|
23
24
|
|
|
24
25
|
private var playerItemBufferEmptyObserver: NSKeyValueObservation?
|
|
25
26
|
private var playerItemBufferKeepUpObserver: NSKeyValueObservation?
|
|
26
27
|
private var playerItemBufferFullObserver: NSKeyValueObservation?
|
|
27
28
|
|
|
28
29
|
// MARK: 'VdoCipherRNView' lifecycle functions
|
|
29
|
-
|
|
30
|
+
var playerState: PlayerState = .unknown {
|
|
30
31
|
didSet{
|
|
31
32
|
if oldValue != playerState {
|
|
32
33
|
EventEmitter.sharedInstance.dispatch(name: .EVENT_PLAYER_STATE_CHANGED, params: [Keys.EVENT_PROP_PLAYER_STATE.rawValue : playerState.rawValue, Keys.EVENT_PROP_PLAY_WHEN_READY.rawValue : self.playWhenReady])
|
|
@@ -36,6 +37,7 @@ class VdoCipherRNView: UIView {
|
|
|
36
37
|
|
|
37
38
|
override init(frame: CGRect) {
|
|
38
39
|
super.init(frame: frame)
|
|
40
|
+
VdoCipher.enableAutoPlay = self.playWhenReady
|
|
39
41
|
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.rn.VdoFramework")
|
|
40
42
|
userDefaults?.set(["name": "react-native", "version": VdocipherRnBridge.vdocipherRnBridgeVersionString], forKey: "rnToolkitInfo")
|
|
41
43
|
VdoCipher.setPlaybackDelegate(delegate: self)
|
|
@@ -118,16 +120,6 @@ class VdoCipherRNView: UIView {
|
|
|
118
120
|
self.player = player
|
|
119
121
|
self.removeObservers()
|
|
120
122
|
self.addObserversToPlayer()
|
|
121
|
-
|
|
122
|
-
guard let asset = asset else { return }
|
|
123
|
-
let mInfo = Media(mediaId: asset.videoId,
|
|
124
|
-
type: playbackType.rawValue,
|
|
125
|
-
title: asset.title ?? "",
|
|
126
|
-
description: asset.description,
|
|
127
|
-
duration: (Int(asset.duration ?? 0.0) * 1000) )
|
|
128
|
-
guard let eventInfo = getJSONEncodedEventDictionary(info: mInfo) else { return }
|
|
129
|
-
EventEmitter.sharedInstance.dispatch(name: EventName.EVENT_LOADED,
|
|
130
|
-
params: [Keys.EVENT_PROP_MEDIA_INFO.rawValue : eventInfo])
|
|
131
123
|
}
|
|
132
124
|
|
|
133
125
|
private func sendPlayerProgress() {
|
|
@@ -171,16 +163,20 @@ class VdoCipherRNView: UIView {
|
|
|
171
163
|
}
|
|
172
164
|
|
|
173
165
|
func parseOnlineCredentials(fromInfo embedInfo: [String: Any]) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
if let token = embedInfo["token"] as? String, let videoId = embedInfo["mediaId"] as? String, !token.isEmpty, !videoId.isEmpty {
|
|
167
|
+
self.playbackType = .streaming
|
|
168
|
+
self.initiatePlayback(withInfo: embedInfo, videoId: videoId, onlineCredentials: Credentials(token: token, playbackInfo: nil, tokenType: .token))
|
|
169
|
+
} else if let playbackInfo = embedInfo["playbackInfo"] as? String,
|
|
170
|
+
let otp = embedInfo["otp"] as? String,
|
|
171
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
172
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded), !otp.isEmpty {
|
|
173
|
+
self.playbackType = .streaming
|
|
174
|
+
self.initiatePlayback(withInfo: embedInfo, videoId: parsed.videoId, onlineCredentials: Credentials(token: otp, playbackInfo: playbackInfo, tokenType: .otp))
|
|
175
|
+
} else {
|
|
178
176
|
let errorDescription = ErrorDescription(errorCode: 4101, errorMsg: "Error: 4101 Invalid video parameters. Please contact the app developer.", httpStatusCode: -1)
|
|
179
177
|
self.sendErrorEventWithDescription(errorDescription)
|
|
180
178
|
return
|
|
181
179
|
}
|
|
182
|
-
self.playbackType = .streaming
|
|
183
|
-
self.initiatePlayback(withInfo: embedInfo, videoId: parsed.videoId, onlineCredentials: Credentials(otp: otp, playbackInfo: playbackInfo))
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
private func initiatePlayback(withInfo embedInfo: [String: Any], videoId: String, onlineCredentials: Credentials? = nil) {
|
|
@@ -205,9 +201,16 @@ class VdoCipherRNView: UIView {
|
|
|
205
201
|
}
|
|
206
202
|
self.asset = asset
|
|
207
203
|
TrackSelection.asset = asset
|
|
204
|
+
if let resumeTime = embedInfo["resumeTimeMs"] as? Int {
|
|
205
|
+
self.setResumeTime(resumeTime)
|
|
206
|
+
}
|
|
208
207
|
self.preferredCaptionsLanguage = preferredCaptionsLanguage
|
|
209
208
|
if let onlineCredentials = onlineCredentials {
|
|
210
|
-
|
|
209
|
+
if onlineCredentials.tokenType == .otp {
|
|
210
|
+
asset.playOnline(otp: onlineCredentials.token, playbackInfo: onlineCredentials.playbackInfo!)
|
|
211
|
+
} else {
|
|
212
|
+
asset.playOnline(token: onlineCredentials.token)
|
|
213
|
+
}
|
|
211
214
|
} else {
|
|
212
215
|
asset.playOffline()
|
|
213
216
|
}
|
|
@@ -215,14 +218,41 @@ class VdoCipherRNView: UIView {
|
|
|
215
218
|
})
|
|
216
219
|
}
|
|
217
220
|
|
|
221
|
+
func setResumeTime(_ resumeTime: Int) {
|
|
222
|
+
guard let asset = self.asset else {return}
|
|
223
|
+
if resumeTime > 0 {
|
|
224
|
+
self.resumeTime = CMTime(value: CMTimeValue(resumeTime), timescale: 1000)
|
|
225
|
+
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.VdoFramework")
|
|
226
|
+
if var assetsLastPlaybackTimeSet = userDefaults?.value(forKey: "assetsLastPlaybackTimeSet") as? [String: Double] {
|
|
227
|
+
assetsLastPlaybackTimeSet[asset.videoId] = Double(resumeTime)
|
|
228
|
+
userDefaults?.set(assetsLastPlaybackTimeSet, forKey: "assetsLastPlaybackTimeSet")
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
218
233
|
// MARK: APIs
|
|
219
234
|
@objc func playerReadyToPlay() {
|
|
235
|
+
guard let asset = asset else { return }
|
|
236
|
+
let mInfo = Media(mediaId: asset.videoId,
|
|
237
|
+
type: playbackType.rawValue,
|
|
238
|
+
title: asset.title ?? "",
|
|
239
|
+
description: asset.description,
|
|
240
|
+
duration: (Int(asset.duration ?? 0.0) * 1000) )
|
|
241
|
+
guard let eventInfo = getJSONEncodedEventDictionary(info: mInfo) else { return }
|
|
242
|
+
EventEmitter.sharedInstance.dispatch(name: EventName.EVENT_LOADED,
|
|
243
|
+
params: [Keys.EVENT_PROP_MEDIA_INFO.rawValue : eventInfo])
|
|
220
244
|
self.playerState = .ready
|
|
221
245
|
if self.preferredCaptionsLanguage?.isEmpty == false {
|
|
222
246
|
DispatchQueue.main.async {
|
|
223
247
|
_ = self.setCaptionLanguage(lanCode: self.preferredCaptionsLanguage)
|
|
224
248
|
}
|
|
225
249
|
}
|
|
250
|
+
if let resumeTime = self.resumeTime {
|
|
251
|
+
player?.seek(to: resumeTime, completionHandler: { [weak self] _ in
|
|
252
|
+
self?.player?.rate = self?.playWhenReady == true ? self?.targetPlaybackSpeed ?? 1.0 : 0
|
|
253
|
+
})
|
|
254
|
+
return
|
|
255
|
+
}
|
|
226
256
|
if self.playWhenReady == true {
|
|
227
257
|
self.player?.rate = targetPlaybackSpeed
|
|
228
258
|
} else {
|
|
@@ -238,6 +268,9 @@ class VdoCipherRNView: UIView {
|
|
|
238
268
|
|
|
239
269
|
@objc func setPlayWhenReady(_ playWhenReady: Bool) {
|
|
240
270
|
self.playWhenReady = playWhenReady
|
|
271
|
+
if playerState != .ready {
|
|
272
|
+
VdoCipher.enableAutoPlay = self.playWhenReady
|
|
273
|
+
}
|
|
241
274
|
if playWhenReady == true {
|
|
242
275
|
if targetPlaybackSpeed == 0 {
|
|
243
276
|
targetPlaybackSpeed = 1.0
|
|
@@ -260,7 +293,6 @@ class VdoCipherRNView: UIView {
|
|
|
260
293
|
|
|
261
294
|
@objc func setSeek(_ seekTime: Int) {
|
|
262
295
|
self.player?.seek(to: CMTime(value: CMTimeValue(seekTime), timescale: 1000))
|
|
263
|
-
|
|
264
296
|
}
|
|
265
297
|
|
|
266
298
|
@objc func setCaptionLanguage(_ caption: [String: Any]) {
|
|
@@ -286,9 +318,6 @@ class VdoCipherRNView: UIView {
|
|
|
286
318
|
|
|
287
319
|
let selectedQuality = asset.getVideoQualities()[index-1]
|
|
288
320
|
asset.enableManualAdaptation(selectedQuality)
|
|
289
|
-
self.sendTrackChangeEvent()
|
|
290
|
-
self.removeObservers()
|
|
291
|
-
self.addObserversToPlayer()
|
|
292
321
|
}
|
|
293
322
|
|
|
294
323
|
@objc func setAdaptiveVideo(_ val: Bool) {
|
|
@@ -296,9 +325,6 @@ class VdoCipherRNView: UIView {
|
|
|
296
325
|
val == true else {return}
|
|
297
326
|
|
|
298
327
|
asset.enableAutoAdaptation()
|
|
299
|
-
self.sendTrackChangeEvent()
|
|
300
|
-
self.removeObservers()
|
|
301
|
-
self.addObserversToPlayer()
|
|
302
328
|
}
|
|
303
329
|
|
|
304
330
|
func setCaptionLanguage(lanCode: String?) -> Bool {
|
|
@@ -374,8 +400,15 @@ extension VdoCipherRNView: AssetPlaybackDelegate {
|
|
|
374
400
|
}
|
|
375
401
|
|
|
376
402
|
func streamPlaybackManager(playerCurrentItemDidChange player: AVPlayer) {
|
|
403
|
+
|
|
377
404
|
self.setUpPlayer(player)
|
|
378
405
|
}
|
|
406
|
+
|
|
407
|
+
func streamPlaybackManager(qualityChangedTo quality: VdoAsset.VideoQuality?) {
|
|
408
|
+
self.sendTrackChangeEvent()
|
|
409
|
+
self.removeObservers()
|
|
410
|
+
self.addObserversToPlayer()
|
|
411
|
+
}
|
|
379
412
|
}
|
|
380
413
|
|
|
381
414
|
extension VdoCipherRNView: VdoPlayerViewControllerDelegate {
|
|
@@ -414,16 +447,21 @@ extension VdoCipherRNView: UINavigationControllerDelegate {
|
|
|
414
447
|
}
|
|
415
448
|
}
|
|
416
449
|
|
|
417
|
-
|
|
450
|
+
enum PlayerState : String {
|
|
418
451
|
case buffering = "buffering",
|
|
419
452
|
ready = "ready",
|
|
420
453
|
ended = "ended",
|
|
421
454
|
unknown = "unknown"
|
|
422
455
|
}
|
|
423
456
|
|
|
424
|
-
|
|
425
|
-
let
|
|
426
|
-
let playbackInfo: String
|
|
457
|
+
struct Credentials {
|
|
458
|
+
let token: String
|
|
459
|
+
let playbackInfo: String?
|
|
460
|
+
let tokenType: TokenType
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
enum TokenType {
|
|
464
|
+
case token, otp
|
|
427
465
|
}
|
|
428
466
|
|
|
429
467
|
private enum PlaybackType: String {
|
package/ios/VdoDownload.swift
CHANGED
|
@@ -25,7 +25,9 @@ class DownloadEventEmitter {
|
|
|
25
25
|
|
|
26
26
|
func dispatch(name: DownloadEventName, params: [String: Any]?) {
|
|
27
27
|
if DownloadEventEmitter.eventEmitter.hasListener == true {
|
|
28
|
-
|
|
28
|
+
DispatchQueue.main.async {
|
|
29
|
+
DownloadEventEmitter.eventEmitter.sendEvent(withName: name.rawValue, body: params)
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -160,17 +162,29 @@ class VdoDownload: RCTEventEmitter {
|
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
@objc func getDownloadOptions(_ optionParams: [String: Any], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
var videoId = ""
|
|
166
|
+
var nativeId = ""
|
|
167
|
+
if let token = optionParams["token"] as? String,
|
|
168
|
+
let mediaId = optionParams["mediaId"] as? String,
|
|
169
|
+
!token.isEmpty,
|
|
170
|
+
!mediaId.isEmpty {
|
|
171
|
+
videoId = mediaId
|
|
172
|
+
nativeId = mediaId
|
|
173
|
+
}
|
|
174
|
+
else if let playbackInfo = optionParams["playbackInfo"] as? String,
|
|
175
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
176
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded),
|
|
177
|
+
let otp = optionParams["otp"] as? String, !otp.isEmpty {
|
|
178
|
+
videoId = parsed.videoId
|
|
179
|
+
nativeId = playbackInfo
|
|
180
|
+
} else {
|
|
167
181
|
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
168
|
-
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "
|
|
182
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Please check credentials"]])
|
|
169
183
|
|
|
170
184
|
return
|
|
171
185
|
}
|
|
172
186
|
let customPlayerId = optionParams["customPlayerId"] as? String
|
|
173
|
-
VdoAsset.createAsset(videoId:
|
|
187
|
+
VdoAsset.createAsset(videoId: videoId, playerId: customPlayerId, onLoad: { asset, err in
|
|
174
188
|
guard let asset = asset else {
|
|
175
189
|
if let error = err {
|
|
176
190
|
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: error.code,
|
|
@@ -193,39 +207,76 @@ class VdoDownload: RCTEventEmitter {
|
|
|
193
207
|
self.optionParams = optionParams
|
|
194
208
|
let mediaInfo = CreateMap.sharedInstance.createMediaInfoMap(with: asset)
|
|
195
209
|
let downloadOptions = CreateMap.sharedInstance.createDownloadOptionsMap(with: availableTracks, mediaInfo: mediaInfo)
|
|
196
|
-
let downloadOptionsMap = [
|
|
210
|
+
let downloadOptionsMap = [nativeId, downloadOptions] as [Any]
|
|
197
211
|
successCallback(downloadOptionsMap)
|
|
198
212
|
})
|
|
199
213
|
}
|
|
200
214
|
|
|
201
215
|
@objc func enqueueDownload(_ nativeId: String, requestOptions: [String: Any], errorCallback: @escaping RCTResponseSenderBlock, successCallback: @escaping RCTResponseSenderBlock) {
|
|
202
|
-
guard let optionParams = optionParams
|
|
216
|
+
guard let optionParams = optionParams else {
|
|
203
217
|
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
204
218
|
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "PlaybackInfo or OTP not found"]])
|
|
205
219
|
return
|
|
206
220
|
}
|
|
207
|
-
if
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
221
|
+
if let token = optionParams["token"] as? String,
|
|
222
|
+
let mediaId = optionParams["mediaId"] as? String {
|
|
223
|
+
if nativeId != mediaId {
|
|
224
|
+
// 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.
|
|
225
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
226
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Call getDownloadOptions before calling enqueue"]])
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
guard let asset = asset else {
|
|
230
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
231
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Unknown error occured"]])
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
VdoDownload.saveCustomPlayerIdForMediaId(asset.videoId, playerId: optionParams["customPlayerId"] as? String)
|
|
235
|
+
if let selections = requestOptions["selections"] as? [Int],
|
|
236
|
+
let index = selections.first,
|
|
237
|
+
asset.getVideoQualities().count > index {
|
|
238
|
+
// assuming index from 'availableTracksMap' is equivalent to index of 'asset.getVideoQualities()' as both are ordered pairs
|
|
239
|
+
asset.percentDownload = 0
|
|
240
|
+
successCallback([])
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
asset.startDownload(token: token)
|
|
244
|
+
} else {
|
|
245
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
246
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Invalid selection"]])
|
|
247
|
+
}
|
|
217
248
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
asset
|
|
249
|
+
else if let otp = optionParams["otp"] as? String, let playbackInfo = optionParams["playbackInfo"] as? String {
|
|
250
|
+
if nativeId != playbackInfo {
|
|
251
|
+
// 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.
|
|
252
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
253
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Call getDownloadOptions before calling enqueue"]])
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
guard let asset = asset else {
|
|
257
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
258
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Unknown error occured"]])
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
VdoDownload.saveCustomPlayerIdForMediaId(asset.videoId, playerId: optionParams["customPlayerId"] as? String)
|
|
262
|
+
if let selections = requestOptions["selections"] as? [Int],
|
|
263
|
+
let index = selections.first,
|
|
264
|
+
asset.getVideoQualities().count > index {
|
|
265
|
+
// assuming index from 'availableTracksMap' is equivalent to index of 'asset.getVideoQualities()' as both are ordered pairs
|
|
266
|
+
asset.percentDownload = 0
|
|
267
|
+
successCallback([])
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
asset.startDownload(otp: otp, playbackInfo: playbackInfo, videoQuality: asset.getVideoQualities()[index])
|
|
271
|
+
} else {
|
|
272
|
+
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
273
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "Invalid selection"]])
|
|
274
|
+
}
|
|
275
|
+
|
|
226
276
|
} else {
|
|
227
277
|
errorCallback([[Error_Keys.EVENT_PROP_ERROR_CODE.rawValue: "-1",
|
|
228
|
-
|
|
278
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue: "PlaybackInfo or OTP not found"]])
|
|
279
|
+
return
|
|
229
280
|
}
|
|
230
281
|
}
|
|
231
282
|
|
|
@@ -5,13 +5,14 @@ import VdoFramework
|
|
|
5
5
|
@objc(VdocipherRnBridge)
|
|
6
6
|
class VdocipherRnBridge: RCTViewManager {
|
|
7
7
|
|
|
8
|
-
static let vdocipherRnBridgeVersionString = "1.
|
|
8
|
+
static let vdocipherRnBridgeVersionString = "1.20.0"
|
|
9
9
|
|
|
10
10
|
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
11
11
|
return true
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
private var playerViewController: AVPlayerViewController?
|
|
15
|
+
private var resumeTime: CMTime?
|
|
15
16
|
|
|
16
17
|
@objc func startVideoScreen(_ embedInfo: [String: Any], setPictureInPictureSupport: Bool) {
|
|
17
18
|
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.rn.VdoFramework")
|
|
@@ -30,20 +31,34 @@ class VdocipherRnBridge: RCTViewManager {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
VdoCipher.setPlaybackDelegate(delegate: self)
|
|
33
|
-
guard let
|
|
34
|
-
let customPlayerId =
|
|
35
|
-
let preferredCaptionsLanguage =
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
guard let embedInfo = embedInfo["embedInfo"] as? [String: Any] else {return}
|
|
35
|
+
let customPlayerId = embedInfo["customPlayerId"] as? String
|
|
36
|
+
let preferredCaptionsLanguage = embedInfo["preferredCaptionsLanguage"] as? String
|
|
37
|
+
var credentials: Credentials?
|
|
38
|
+
var videoId: String?
|
|
39
|
+
if let token = embedInfo["token"] as? String, let mediaId = embedInfo["mediaId"] as? String, !token.isEmpty, !mediaId.isEmpty {
|
|
40
|
+
credentials = Credentials(token: token, playbackInfo: nil, tokenType: .token)
|
|
41
|
+
videoId = mediaId
|
|
42
|
+
} else if let playbackInfo = embedInfo["playbackInfo"] as? String,
|
|
43
|
+
let otp = embedInfo["otp"] as? String,
|
|
44
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
45
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded), !otp.isEmpty {
|
|
46
|
+
credentials = Credentials(token: otp, playbackInfo: playbackInfo, tokenType: .otp)
|
|
47
|
+
videoId = parsed.videoId
|
|
48
|
+
} else {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
let resumeTimeMs = embedInfo["resumeTimeMs"] as? Int
|
|
38
52
|
let resumeTime = Float(resumeTimeMs ?? 0)
|
|
39
53
|
if resumeTime > 0 {
|
|
54
|
+
self.resumeTime = CMTime(value: CMTimeValue(resumeTime), timescale: 1000)
|
|
40
55
|
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.VdoFramework")
|
|
41
56
|
if var assetsLastPlaybackTimeSet = userDefaults?.value(forKey: "assetsLastPlaybackTimeSet") as? [String: Double] {
|
|
42
|
-
assetsLastPlaybackTimeSet[
|
|
57
|
+
assetsLastPlaybackTimeSet[videoId!] = Double(resumeTime)
|
|
43
58
|
userDefaults?.set(assetsLastPlaybackTimeSet, forKey: "assetsLastPlaybackTimeSet")
|
|
44
59
|
}
|
|
45
60
|
}
|
|
46
|
-
VdoAsset.createAsset(videoId:
|
|
61
|
+
VdoAsset.createAsset(videoId: videoId!, playerId: customPlayerId, onLoad: { asset, err in
|
|
47
62
|
DispatchQueue.main.async {
|
|
48
63
|
guard let asset = asset else {
|
|
49
64
|
return
|
|
@@ -57,10 +72,15 @@ class VdocipherRnBridge: RCTViewManager {
|
|
|
57
72
|
break
|
|
58
73
|
}
|
|
59
74
|
}
|
|
75
|
+
VdoCipher.enableAutoPlay = true
|
|
60
76
|
if asset.downloadState == .downloaded {
|
|
61
77
|
asset.playOffline()
|
|
62
78
|
} else {
|
|
63
|
-
|
|
79
|
+
if credentials?.tokenType == .otp {
|
|
80
|
+
asset.playOnline(otp: credentials!.token, playbackInfo: credentials!.playbackInfo!)
|
|
81
|
+
} else {
|
|
82
|
+
asset.playOnline(token: credentials!.token)
|
|
83
|
+
}
|
|
64
84
|
}
|
|
65
85
|
}
|
|
66
86
|
})
|
|
@@ -76,6 +96,9 @@ extension VdocipherRnBridge: AssetPlaybackDelegate {
|
|
|
76
96
|
|
|
77
97
|
func streamPlaybackManager(playerCurrentItemDidChange player: AVPlayer) {
|
|
78
98
|
self.playerViewController?.player = player
|
|
99
|
+
if let resumeTime = self.resumeTime {
|
|
100
|
+
player.seek(to: resumeTime)
|
|
101
|
+
}
|
|
79
102
|
}
|
|
80
103
|
|
|
81
104
|
func streamLoadError(error: VdoFramework.VdoError) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdocipher-rn-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
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": {
|
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency "VdoFramework", "2.5.
|
|
20
|
+
s.dependency "VdoFramework", "2.5.5"
|
|
21
21
|
|
|
22
22
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
23
23
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
package/type.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type EmbedInfo = OtpEmbedInfo | TokenEmbedInfo;
|
|
4
|
+
|
|
5
|
+
export interface OtpEmbedInfo {
|
|
4
6
|
otp: string;
|
|
5
7
|
playbackInfo: string;
|
|
6
8
|
/**
|
|
@@ -33,6 +35,42 @@ export interface EmbedInfo {
|
|
|
33
35
|
* Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
|
|
34
36
|
*/
|
|
35
37
|
setPictureInPictureSupport?: boolean | null;
|
|
38
|
+
resumeTimeMs?: number | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TokenEmbedInfo {
|
|
42
|
+
token: string;
|
|
43
|
+
mediaId: string;
|
|
44
|
+
/**
|
|
45
|
+
* Not supported in iOS
|
|
46
|
+
*/
|
|
47
|
+
forceLowestBitrate?: boolean | null;
|
|
48
|
+
/**
|
|
49
|
+
* Not supported in iOS
|
|
50
|
+
*/
|
|
51
|
+
forceHighestSupportedBitrate?: boolean | null;
|
|
52
|
+
/**
|
|
53
|
+
* Not supported in iOS
|
|
54
|
+
*/
|
|
55
|
+
maxVideoBitrateKbps?: number | null;
|
|
56
|
+
/**
|
|
57
|
+
* Not supported in iOS
|
|
58
|
+
*/
|
|
59
|
+
bufferingGoalMs?: number | null;
|
|
60
|
+
enableAutoResume?: boolean | null;
|
|
61
|
+
preferredCaptionsLanguage?: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
* Use {@link customPlayerId} instead.
|
|
65
|
+
*/
|
|
66
|
+
playerConfig?: string | null;
|
|
67
|
+
customPlayerId?: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated
|
|
70
|
+
* This property is no longer required to enable PIP mode.
|
|
71
|
+
* Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
|
|
72
|
+
*/
|
|
73
|
+
setPictureInPictureSupport?: boolean | null;
|
|
36
74
|
}
|
|
37
75
|
|
|
38
76
|
export type OfflineEmbedInfo = {
|
|
@@ -51,11 +89,14 @@ export type OfflineEmbedInfo = {
|
|
|
51
89
|
* Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
|
|
52
90
|
*/
|
|
53
91
|
setPictureInPictureSupport?: boolean | null;
|
|
92
|
+
resumeTimeMs?: number | null;
|
|
54
93
|
}
|
|
55
94
|
|
|
56
95
|
export type OfflineOptionParams = {
|
|
57
96
|
otp: string;
|
|
58
97
|
playbackInfo: string;
|
|
98
|
+
token: string;
|
|
99
|
+
mediaId: string;
|
|
59
100
|
customPlayerId?: string;
|
|
60
101
|
}
|
|
61
102
|
|
|
@@ -156,6 +197,19 @@ export const VdoPropTypes = {
|
|
|
156
197
|
preferredCaptionsLanguage: PropTypes.string,
|
|
157
198
|
playerConfig: PropTypes.string,
|
|
158
199
|
customPlayerId: PropTypes.string,
|
|
200
|
+
resumeTimeMs: PropTypes.number,
|
|
201
|
+
}),
|
|
202
|
+
PropTypes.shape({
|
|
203
|
+
token: PropTypes.string.isRequired,
|
|
204
|
+
mediaId: PropTypes.string.isRequired,
|
|
205
|
+
forceLowestBitrate: PropTypes.bool,
|
|
206
|
+
forceHighestSupportedBitrate: PropTypes.bool,
|
|
207
|
+
maxVideoBitrateKbps: PropTypes.number,
|
|
208
|
+
bufferingGoalMs: PropTypes.number,
|
|
209
|
+
enableAutoResume: PropTypes.bool,
|
|
210
|
+
preferredCaptionsLanguage: PropTypes.string,
|
|
211
|
+
playerConfig: PropTypes.string,
|
|
212
|
+
customPlayerId: PropTypes.string,
|
|
159
213
|
}),
|
|
160
214
|
PropTypes.shape({
|
|
161
215
|
offline: PropTypes.bool.isRequired,
|
|
@@ -163,6 +217,7 @@ export const VdoPropTypes = {
|
|
|
163
217
|
enableAutoResume: PropTypes.bool,
|
|
164
218
|
preferredCaptionsLanguage: PropTypes.string,
|
|
165
219
|
playerConfig: PropTypes.string,
|
|
220
|
+
resumeTimeMs: PropTypes.number,
|
|
166
221
|
})
|
|
167
222
|
]).isRequired,
|
|
168
223
|
style: PropTypes.shape({
|
package/ios/Podfile.lock
DELETED