vdocipher-rn-bridge 1.16.0 → 1.17.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/CHANGELOG.md +11 -0
- package/VdoPlayerUIView.tsx +10 -10
- package/VdoPlayerView.tsx +170 -70
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +13 -7
- package/android/src/main/java/com/vdocipher/rnbridge/VdoDownloadModule.java +67 -0
- package/downloadMonitor.ts +2 -2
- package/downloads.ts +63 -1
- package/index.ts +4 -1
- package/ios/Podfile +10 -0
- package/ios/Podfile.lock +3 -0
- package/ios/Pods/Manifest.lock +3 -0
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +397 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/mansisharma.xcuserdatad/xcschemes/Pods-VdocipherRnBridge.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/mansisharma.xcuserdatad/xcschemes/xcschememanagement.plist +16 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-acknowledgements.markdown +3 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-acknowledgements.plist +29 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.debug.xcconfig +8 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.modulemap +6 -0
- package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.release.xcconfig +8 -0
- package/ios/RCTVdoPlayerUIView.h +19 -0
- package/ios/RCTVdoPlayerUIView.swift +74 -0
- package/ios/RCTVdoPlayerView.h +18 -0
- package/ios/RCTVdoPlayerView.swift +84 -0
- package/ios/TrackSelection.swift +64 -0
- package/ios/VdoCipherRNView.h +18 -0
- package/ios/VdoCipherRNView.swift +312 -0
- package/ios/VdoDownload.swift +103 -0
- package/ios/VdoEventEmitter.swift +157 -0
- package/ios/VdoPlaybackProperties.h +19 -0
- package/ios/VdoPlaybackProperties.swift +21 -0
- package/ios/VdocipherRnBridge.h +2 -10
- package/ios/VdocipherRnBridgeViewManager.m +99 -0
- package/ios/VdocipherRnBridgeViewManager.swift +90 -0
- package/package.json +3 -2
- package/react-native-vdocipher-rn-bridge.podspec +36 -0
- package/type.ts +23 -0
- package/ios/VdocipherRnBridge.m +0 -13
- package/ios/VdocipherRnBridge.xcodeproj/project.pbxproj +0 -259
- package/ios/VdocipherRnBridge.xcworkspace/contents.xcworkspacedata +0 -9
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VdoEventEmitter.swift
|
|
3
|
+
// react-native-vdocipher-rn-bridge
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 05/06/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import React
|
|
10
|
+
|
|
11
|
+
class EventEmitter {
|
|
12
|
+
|
|
13
|
+
/// Shared Instance.
|
|
14
|
+
public static var sharedInstance = EventEmitter()
|
|
15
|
+
|
|
16
|
+
// ReactNativeEventEmitter is instantiated by React Native with the bridge.
|
|
17
|
+
private static var eventEmitter: VdoEventEmitter!
|
|
18
|
+
|
|
19
|
+
let errorParsingFailDefaultErrInfo: [String: Any] = [Error_Keys.EVENT_PROP_ERROR_CODE.rawValue : -1,
|
|
20
|
+
Error_Keys.EVENT_PROP_ERROR_MSG.rawValue : "Error parsing failed, no error code and description available.",
|
|
21
|
+
Error_Keys.EVENT_PROP_ERROR_HTTP_CODE.rawValue : -1]
|
|
22
|
+
|
|
23
|
+
private init() {}
|
|
24
|
+
|
|
25
|
+
// When React Native instantiates the emitter it is registered here.
|
|
26
|
+
func registerEventEmitter(eventEmitter: VdoEventEmitter) {
|
|
27
|
+
EventEmitter.eventEmitter = eventEmitter
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func dispatch(name: EventName, params: [String: Any]?) {
|
|
31
|
+
if EventEmitter.eventEmitter.hasListener == true {
|
|
32
|
+
var data = [String: Any] ()
|
|
33
|
+
if let p = params {
|
|
34
|
+
data["nativeEvent"] = p
|
|
35
|
+
}
|
|
36
|
+
// print("event data sent is \(data)")
|
|
37
|
+
EventEmitter.eventEmitter.sendEvent(withName: name.rawValue, body: data)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// All Events which must be support by React Native.
|
|
42
|
+
lazy var allEvents: [String] = {
|
|
43
|
+
|
|
44
|
+
return EventName.allCases.map { $0.rawValue }
|
|
45
|
+
}()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
enum EventName: String, CaseIterable {
|
|
50
|
+
case EVENT_INIT_SUCCESS = "onInitSuccess"
|
|
51
|
+
case EVENT_INIT_FAILURE = "onInitFailure"
|
|
52
|
+
case EVENT_LOADING = "onVdoLoading"
|
|
53
|
+
case EVENT_LOADED = "onVdoLoaded"
|
|
54
|
+
case EVENT_LOAD_ERROR = "onVdoLoadError"
|
|
55
|
+
case EVENT_PLAYER_STATE_CHANGED = "onVdoPlayerStateChanged"
|
|
56
|
+
case EVENT_PROGRESS = "onVdoProgress"
|
|
57
|
+
case EVENT_BUFFER_UPDATE = "onVdoBufferUpdate"
|
|
58
|
+
case EVENT_PLAYBACK_SPEED_CHANGED = "onVdoPlaybackSpeedChanged"
|
|
59
|
+
case EVENT_TRACKS_CHANGED = "onVdoTracksChanged"
|
|
60
|
+
case EVENT_MEDIA_ENDED = "onVdoMediaEnded"
|
|
61
|
+
case EVENT_ERROR = "onVdoError"
|
|
62
|
+
case EVENT_PLAYBACK_PROPERTIES = "onVdoPlaybackProperties"
|
|
63
|
+
case EVENT_ENTER_FULLSCREEN = "onVdoEnterFullscreen"
|
|
64
|
+
case EVENT_EXIT_FULLSCREEN = "onVdoExitFullscreen"
|
|
65
|
+
case EVENT_IS_INITIAL_PORTRAIT = "onIsInitialPortrait"
|
|
66
|
+
case EVENT_PICTURE_IN_PICTURE_MODE_CHANGED = "onVdoPictureInPictureModeChanged"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
enum Keys: String {
|
|
70
|
+
case EVENT_PROP_RESTORED = "restored"
|
|
71
|
+
case EVENT_PROP_MEDIA_INFO = "mediaInfo"
|
|
72
|
+
case EVENT_PROP_CURRENT_TIME = "currentTime"
|
|
73
|
+
case EVENT_PROP_BUFFER_TIME = "bufferTime"
|
|
74
|
+
case EVENT_PROP_SEEK_TIME = "seekTime"
|
|
75
|
+
case EVENT_PROP_ORIENTATION = "orientation"
|
|
76
|
+
case EVENT_PROP_AVAILABLE_TRACKS = "availableTracks"
|
|
77
|
+
case EVENT_PROP_SELECTED_TRACKS = "selectedTracks"
|
|
78
|
+
case EVENT_PROP_PLAY_WHEN_READY = "playWhenReady"
|
|
79
|
+
case EVENT_PROP_PLAYER_STATE = "playerState"
|
|
80
|
+
case EVENT_PROP_PLAYBACK_SPEED = "playbackSpeed"
|
|
81
|
+
case EVENT_PROP_IS_INITIAL_PORTRAIT = "isInitialPortrait"
|
|
82
|
+
case EVENT_PROP_IS_IN_PICTURE_IN_PICTURE_MODE = "isInPictureInPictureMode"
|
|
83
|
+
case EVENT_PROP_ERROR_DESCRIPTION = "errorDescription"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
enum Error_Keys: String {
|
|
87
|
+
case EVENT_PROP_ERROR_CODE = "errorCode"
|
|
88
|
+
case EVENT_PROP_ERROR_MSG = "errorMsg"
|
|
89
|
+
case EVENT_PROP_ERROR_HTTP_CODE = "httpStatusCode"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
struct ErrorDescription: Encodable {
|
|
93
|
+
let errorCode: Int
|
|
94
|
+
let errorMsg: String
|
|
95
|
+
let httpStatusCode: Int
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
struct Media: Encodable {
|
|
99
|
+
let mediaId: String
|
|
100
|
+
let type: String
|
|
101
|
+
let title: String
|
|
102
|
+
let description: String
|
|
103
|
+
let duration: Int
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@objc(VdoEventEmitter)
|
|
108
|
+
class VdoEventEmitter: RCTEventEmitter {
|
|
109
|
+
|
|
110
|
+
override init() {
|
|
111
|
+
super.init()
|
|
112
|
+
// print("\(type(of: self))).\(#function)")
|
|
113
|
+
EventEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var hasListener: Bool?
|
|
117
|
+
|
|
118
|
+
/// Base overide for RCTEventEmitter.
|
|
119
|
+
///
|
|
120
|
+
/// - Returns: all supported events
|
|
121
|
+
@objc open override func supportedEvents() -> [String] {
|
|
122
|
+
// print("\(type(of: self))).\(#function)")
|
|
123
|
+
return EventEmitter.sharedInstance.allEvents
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@objc open override func startObserving() {
|
|
127
|
+
super.startObserving()
|
|
128
|
+
hasListener = true
|
|
129
|
+
// print("\(type(of: self))).\(#function)")
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@objc open override func stopObserving() {
|
|
133
|
+
super.stopObserving()
|
|
134
|
+
hasListener = false
|
|
135
|
+
// print("\(type(of: self))).\(#function)")
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
open override class func requiresMainQueueSetup() -> Bool {
|
|
139
|
+
// print("\(type(of: self))).\(#function)")
|
|
140
|
+
return true
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
open override func addListener(_ eventName: String!) {
|
|
144
|
+
super.addListener(eventName)
|
|
145
|
+
// print("\(type(of: self))).\(#function) eventName: \(eventName)")
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
open override func removeListeners(_ count: Double) {
|
|
149
|
+
super.removeListeners(count)
|
|
150
|
+
// print("\(type(of: self))).\(#function) count: \(count)")
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
open override func invalidate() {
|
|
154
|
+
super.invalidate()
|
|
155
|
+
// print("\(type(of: self))).\(#function)")
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VdoPlaybackProperties.h
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 07/06/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#ifndef VdoPlaybackProperties_h
|
|
9
|
+
#define VdoPlaybackProperties_h
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#endif /* VdoPlaybackProperties_h */
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@interface VdoPlaybackProperties : NSObject
|
|
16
|
+
|
|
17
|
+
+ (NSDictionary *) getPlaybackProperties;
|
|
18
|
+
|
|
19
|
+
@end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VdoPlaybackProperties.swift
|
|
3
|
+
// react-native-vdocipher-rn-bridge
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 07/06/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import VdoFramework
|
|
10
|
+
|
|
11
|
+
@objc(VdoPlaybackProperties)
|
|
12
|
+
class VdoPlaybackProperties: NSObject {
|
|
13
|
+
|
|
14
|
+
@objc static func getPlaybackProperties() -> [String : Any] {
|
|
15
|
+
let totalPlayed = VdoCipher.getValueOfPlaybackProperty(.totalPlayed)?[VdoCipher.PlaybackProperty.totalPlayed.rawValue] ?? 0
|
|
16
|
+
|
|
17
|
+
let totalCovered = VdoCipher.getValueOfPlaybackProperty(.totalCovered)?[VdoCipher.PlaybackProperty.totalCovered.rawValue] ?? 0
|
|
18
|
+
|
|
19
|
+
return ["totalPlayed": totalPlayed, "totalCovered": totalCovered]
|
|
20
|
+
}
|
|
21
|
+
}
|
package/ios/VdocipherRnBridge.h
CHANGED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#import <React/RCTViewManager.h>
|
|
2
|
+
#import <React/RCTUIManager.h>
|
|
3
|
+
#import <React/RCTLog.h>
|
|
4
|
+
#import <React/RCTEventEmitter.h>
|
|
5
|
+
#import "RCTVdoPlayerUIView.h"
|
|
6
|
+
#import "RCTVdoPlayerView.h"
|
|
7
|
+
#import "VdoPlaybackProperties.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@interface RCT_EXTERN_MODULE(VdocipherRnBridge, RCTViewManager)
|
|
11
|
+
|
|
12
|
+
RCT_EXTERN_METHOD(startVideoScreen: (NSDictionary *) embedInfo setPictureInPictureSupport: (BOOL))
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@interface ReactVdoPlayerUIViewManager : RCTViewManager
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
@implementation ReactVdoPlayerUIViewManager
|
|
21
|
+
|
|
22
|
+
RCT_EXPORT_MODULE(RCTVdoPlayerUIView)
|
|
23
|
+
RCT_EXPORT_VIEW_PROPERTY(embedInfo, NSDictionary *)
|
|
24
|
+
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString *)
|
|
25
|
+
RCT_EXPORT_VIEW_PROPERTY(playWhenReady, BOOL)
|
|
26
|
+
RCT_EXPORT_VIEW_PROPERTY(playbackSpeed, float)
|
|
27
|
+
RCT_EXPORT_VIEW_PROPERTY(seek, int)
|
|
28
|
+
RCT_EXPORT_VIEW_PROPERTY(captionLanguage, NSDictionary *)
|
|
29
|
+
RCT_EXPORT_VIEW_PROPERTY(disableCaptions, int)
|
|
30
|
+
|
|
31
|
+
- (VdoCipherRNView *)view
|
|
32
|
+
{
|
|
33
|
+
return [[RCTVdoPlayerUIView alloc] init];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
@interface ReactVdoPlayerViewManager : RCTViewManager
|
|
39
|
+
@end
|
|
40
|
+
|
|
41
|
+
@implementation ReactVdoPlayerViewManager
|
|
42
|
+
|
|
43
|
+
RCT_EXPORT_MODULE(RCTVdoPlayerView)
|
|
44
|
+
RCT_EXPORT_VIEW_PROPERTY(embedInfo, NSDictionary *)
|
|
45
|
+
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString *)
|
|
46
|
+
RCT_EXPORT_VIEW_PROPERTY(playWhenReady, BOOL)
|
|
47
|
+
RCT_EXPORT_VIEW_PROPERTY(playbackSpeed, float)
|
|
48
|
+
RCT_EXPORT_VIEW_PROPERTY(seek, int)
|
|
49
|
+
RCT_EXPORT_VIEW_PROPERTY(captionLanguage, NSDictionary *)
|
|
50
|
+
RCT_EXPORT_VIEW_PROPERTY(disableCaptions, int)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
- (VdoCipherRNView *)view
|
|
54
|
+
{
|
|
55
|
+
return [[RCTVdoPlayerView alloc] init];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@end
|
|
59
|
+
|
|
60
|
+
@interface RCT_EXTERN_MODULE(VdoEventEmitter, RCTEventEmitter)
|
|
61
|
+
|
|
62
|
+
RCT_EXTERN_METHOD(supportedEvents)
|
|
63
|
+
|
|
64
|
+
@end
|
|
65
|
+
|
|
66
|
+
@interface RCT_EXTERN_MODULE(VdoDownload, RCTEventEmitter)
|
|
67
|
+
|
|
68
|
+
RCT_EXTERN_METHOD(supportedEvents)
|
|
69
|
+
|
|
70
|
+
@end
|
|
71
|
+
|
|
72
|
+
@interface RCT_EXTERN_MODULE(VdoPlayer, NSObject)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@end
|
|
76
|
+
|
|
77
|
+
@implementation VdoPlayer
|
|
78
|
+
|
|
79
|
+
RCT_EXPORT_METHOD(getPlaybackPropertiesV2: (RCTResponseSenderBlock) callback)
|
|
80
|
+
{
|
|
81
|
+
NSDictionary *playbackProperties = VdoPlaybackProperties.getPlaybackProperties;
|
|
82
|
+
printf(@"Playback properties sent are = %@", playbackProperties);
|
|
83
|
+
callback(@[playbackProperties]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@end
|
|
87
|
+
|
|
88
|
+
@interface RCT_EXTERN_MODULE(TrackSelection, NSObject)
|
|
89
|
+
|
|
90
|
+
RCT_EXTERN_METHOD(getCaptionLanguages: (RCTResponseSenderBlock) callback)
|
|
91
|
+
RCT_EXTERN_METHOD(getSelectedCaptionLanguage: (RCTResponseSenderBlock) callback)
|
|
92
|
+
RCT_EXTERN_METHOD(getDuration: (RCTResponseSenderBlock) callback)
|
|
93
|
+
|
|
94
|
+
+ (BOOL)requiresMainQueueSetup
|
|
95
|
+
{
|
|
96
|
+
return YES;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import AVKit
|
|
3
|
+
import VdoFramework
|
|
4
|
+
|
|
5
|
+
@objc(VdocipherRnBridge)
|
|
6
|
+
class VdocipherRnBridge: RCTViewManager {
|
|
7
|
+
|
|
8
|
+
static let vdocipherRnBridgeVersionString = "1.17.0"
|
|
9
|
+
|
|
10
|
+
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private var playerViewController: AVPlayerViewController?
|
|
15
|
+
|
|
16
|
+
@objc func startVideoScreen(_ embedInfo: [String: Any], setPictureInPictureSupport: Bool) {
|
|
17
|
+
// print("REACT LOG ===== start Video Screen Function called from React side.... \(embedInfo)")
|
|
18
|
+
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.rn.VdoFramework")
|
|
19
|
+
userDefaults?.set(["name": "react-native", "version": VdocipherRnBridge.vdocipherRnBridgeVersionString], forKey: "rnToolkitInfo")
|
|
20
|
+
DispatchQueue.main.async {
|
|
21
|
+
guard let window = UIApplication.shared.keyWindow, let rootVC = window.rootViewController else {return}
|
|
22
|
+
if #available(iOS 12, *) {
|
|
23
|
+
if let _ = VdoCipher.getVdoPlayerViewController().parent {
|
|
24
|
+
VdoCipher.getVdoPlayerViewController().removeFromParent()
|
|
25
|
+
}
|
|
26
|
+
let playerUIView = VdoCipher.getVdoPlayerViewController()
|
|
27
|
+
rootVC.present(playerUIView, animated: true)
|
|
28
|
+
} else {
|
|
29
|
+
self.playerViewController = AVPlayerViewController()
|
|
30
|
+
rootVC.present(self.playerViewController!, animated: true)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
VdoCipher.setPlaybackDelegate(delegate: self)
|
|
34
|
+
guard let credentials = embedInfo["embedInfo"] as? [String: Any], let playbackInfo = credentials["playbackInfo"] as? String, let otp = credentials["otp"] as? String else {return}
|
|
35
|
+
let customPlayerId = credentials["customPlayerId"] as? String
|
|
36
|
+
let preferredCaptionsLanguage = credentials["preferredCaptionsLanguage"] as? String
|
|
37
|
+
guard let decoded = Data(base64Encoded: playbackInfo), let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded) else {return}
|
|
38
|
+
let resumeTimeMs = credentials["resumeTimeMs"] as? Int
|
|
39
|
+
let resumeTime = Float(resumeTimeMs ?? 0)
|
|
40
|
+
if resumeTime > 0 {
|
|
41
|
+
let userDefaults: UserDefaults? = UserDefaults.init(suiteName: "com.vdocipher.ios.VdoFramework")
|
|
42
|
+
if var assetsLastPlaybackTimeSet = userDefaults?.value(forKey: "assetsLastPlaybackTimeSet") as? [String: Double] {
|
|
43
|
+
assetsLastPlaybackTimeSet[parsed.videoId] = Double(resumeTime)
|
|
44
|
+
userDefaults?.set(assetsLastPlaybackTimeSet, forKey: "assetsLastPlaybackTimeSet")
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
VdoAsset.createAsset(videoId: parsed.videoId, playerId: customPlayerId, onLoad: { asset, err in
|
|
48
|
+
DispatchQueue.main.async {
|
|
49
|
+
guard let asset = asset else {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
if preferredCaptionsLanguage == nil {
|
|
53
|
+
_ = asset.setCaption(nil)
|
|
54
|
+
}
|
|
55
|
+
for caption in asset.captions ?? [] {
|
|
56
|
+
if caption.lang == preferredCaptionsLanguage {
|
|
57
|
+
_ = asset.setCaption(caption)
|
|
58
|
+
break
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if asset.downloadState == .downloaded {
|
|
62
|
+
asset.playOffline()
|
|
63
|
+
} else {
|
|
64
|
+
asset.playOnline(otp: otp, playbackInfo: playbackInfo)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
extension VdocipherRnBridge: AssetPlaybackDelegate {
|
|
72
|
+
func streamPlaybackManager(playerReadyToPlay player: AVPlayer) {
|
|
73
|
+
if let playerVC = self.playerViewController {
|
|
74
|
+
playerVC.player?.play()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func streamPlaybackManager(playerCurrentItemDidChange player: AVPlayer) {
|
|
79
|
+
self.playerViewController?.player = player
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func streamLoadError(error: VdoFramework.VdoError) {
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
struct PlaybackInfo: Decodable {
|
|
88
|
+
let videoId: String
|
|
89
|
+
}
|
|
90
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdocipher-rn-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.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": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"downloadMonitor.ts",
|
|
30
30
|
"index.ts",
|
|
31
31
|
"tsconfig.json",
|
|
32
|
-
"type.ts"
|
|
32
|
+
"type.ts",
|
|
33
|
+
"react-native-vdocipher-rn-bridge.podspec"
|
|
33
34
|
],
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@tsconfig/react-native": "^2.0.3",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "react-native-vdocipher-rn-bridge"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => "12.4" }
|
|
15
|
+
s.source = { :git => "https://github.com/VdoCipher/vdocipher-react-native.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
+
|
|
19
|
+
s.dependency "React-Core"
|
|
20
|
+
s.dependency "VdoFramework", "2.4.3"
|
|
21
|
+
|
|
22
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
23
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
24
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
25
|
+
s.pod_target_xcconfig = {
|
|
26
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
27
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
s.dependency "React-Codegen"
|
|
31
|
+
s.dependency "RCT-Folly"
|
|
32
|
+
s.dependency "RCTRequired"
|
|
33
|
+
s.dependency "RCTTypeSafety"
|
|
34
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
35
|
+
end
|
|
36
|
+
end
|
package/type.ts
CHANGED
|
@@ -3,11 +3,26 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
export interface EmbedInfo {
|
|
4
4
|
otp: string;
|
|
5
5
|
playbackInfo: string;
|
|
6
|
+
/**
|
|
7
|
+
* Not supported in iOS
|
|
8
|
+
*/
|
|
6
9
|
forceLowestBitrate?: boolean | null;
|
|
10
|
+
/**
|
|
11
|
+
* Not supported in iOS
|
|
12
|
+
*/
|
|
7
13
|
forceHighestSupportedBitrate?: boolean | null;
|
|
14
|
+
/**
|
|
15
|
+
* Not supported in iOS
|
|
16
|
+
*/
|
|
8
17
|
maxVideoBitrateKbps?: number | null;
|
|
18
|
+
/**
|
|
19
|
+
* Not supported in iOS
|
|
20
|
+
*/
|
|
9
21
|
bufferingGoalMs?: number | null;
|
|
10
22
|
enableAutoResume?: boolean | null;
|
|
23
|
+
/**
|
|
24
|
+
* Not supported in iOS
|
|
25
|
+
*/
|
|
11
26
|
safetyNetApiKey?: string | null;
|
|
12
27
|
preferredCaptionsLanguage?: string | null;
|
|
13
28
|
/**
|
|
@@ -28,6 +43,9 @@ export type OfflineEmbedInfo = {
|
|
|
28
43
|
offline: boolean;
|
|
29
44
|
mediaId: string;
|
|
30
45
|
enableAutoResume?: boolean | null;
|
|
46
|
+
/**
|
|
47
|
+
* Not supported in iOS
|
|
48
|
+
*/
|
|
31
49
|
safetyNetApiKey?: string | null;
|
|
32
50
|
preferredCaptionsLanguage?: string | null;
|
|
33
51
|
/**
|
|
@@ -35,6 +53,11 @@ export type OfflineEmbedInfo = {
|
|
|
35
53
|
* This id will be ignored and the customPlayerId passed while downloading will be used
|
|
36
54
|
*/
|
|
37
55
|
playerConfig?: string | null;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated
|
|
58
|
+
* This property is no longer required to enable PIP mode.
|
|
59
|
+
* Use {@link https://developer.android.com/reference/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)} at activity level instead.
|
|
60
|
+
*/
|
|
38
61
|
setPictureInPictureSupport?: boolean | null;
|
|
39
62
|
}
|
|
40
63
|
|