vdocipher-rn-bridge 1.15.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 +27 -0
- package/VdoPlayerSupportView.tsx +6 -4
- package/VdoPlayerUIView.tsx +21 -9
- package/VdoPlayerView.tsx +184 -58
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +47 -32
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +5 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +10 -10
- package/android/src/main/java/com/vdocipher/rnbridge/VdoDownloadModule.java +67 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +1 -10
- 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 -1
- 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,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1240"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "455C7AD88713A1719D6F88C64DB5605A"
|
|
18
|
+
BuildableName = "Pods_VdocipherRnBridge.framework"
|
|
19
|
+
BlueprintName = "Pods-VdocipherRnBridge"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Pods-VdocipherRnBridge.xcscheme</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>isShown</key>
|
|
10
|
+
<false/>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
<key>SuppressBuildableAutocreation</key>
|
|
14
|
+
<dict/>
|
|
15
|
+
</dict>
|
|
16
|
+
</plist>
|
package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-Info.plist
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>${EXECUTABLE_NAME}</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>${PRODUCT_NAME}</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0.0</string>
|
|
19
|
+
<key>CFBundleSignature</key>
|
|
20
|
+
<string>????</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>${CURRENT_PROJECT_VERSION}</string>
|
|
23
|
+
<key>NSPrincipalClass</key>
|
|
24
|
+
<string></string>
|
|
25
|
+
</dict>
|
|
26
|
+
</plist>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>PreferenceSpecifiers</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>FooterText</key>
|
|
9
|
+
<string>This application makes use of the following third party libraries:</string>
|
|
10
|
+
<key>Title</key>
|
|
11
|
+
<string>Acknowledgements</string>
|
|
12
|
+
<key>Type</key>
|
|
13
|
+
<string>PSGroupSpecifier</string>
|
|
14
|
+
</dict>
|
|
15
|
+
<dict>
|
|
16
|
+
<key>FooterText</key>
|
|
17
|
+
<string>Generated by CocoaPods - https://cocoapods.org</string>
|
|
18
|
+
<key>Title</key>
|
|
19
|
+
<string></string>
|
|
20
|
+
<key>Type</key>
|
|
21
|
+
<string>PSGroupSpecifier</string>
|
|
22
|
+
</dict>
|
|
23
|
+
</array>
|
|
24
|
+
<key>StringsTable</key>
|
|
25
|
+
<string>Acknowledgements</string>
|
|
26
|
+
<key>Title</key>
|
|
27
|
+
<string>Acknowledgements</string>
|
|
28
|
+
</dict>
|
|
29
|
+
</plist>
|
package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge-umbrella.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#ifdef __OBJC__
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
#else
|
|
4
|
+
#ifndef FOUNDATION_EXPORT
|
|
5
|
+
#if defined(__cplusplus)
|
|
6
|
+
#define FOUNDATION_EXPORT extern "C"
|
|
7
|
+
#else
|
|
8
|
+
#define FOUNDATION_EXPORT extern
|
|
9
|
+
#endif
|
|
10
|
+
#endif
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
FOUNDATION_EXPORT double Pods_VdocipherRnBridgeVersionNumber;
|
|
15
|
+
FOUNDATION_EXPORT const unsigned char Pods_VdocipherRnBridgeVersionString[];
|
|
16
|
+
|
package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.debug.xcconfig
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
|
|
2
|
+
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
|
3
|
+
PODS_BUILD_DIR = ${BUILD_DIR}
|
|
4
|
+
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
|
5
|
+
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
|
|
6
|
+
PODS_ROOT = ${SRCROOT}/Pods
|
|
7
|
+
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
|
|
8
|
+
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
|
package/ios/Pods/Target Support Files/Pods-VdocipherRnBridge/Pods-VdocipherRnBridge.release.xcconfig
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
|
|
2
|
+
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
|
3
|
+
PODS_BUILD_DIR = ${BUILD_DIR}
|
|
4
|
+
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
|
5
|
+
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
|
|
6
|
+
PODS_ROOT = ${SRCROOT}/Pods
|
|
7
|
+
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
|
|
8
|
+
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTVdoPlayerUIView.h
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 22/05/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#import "VdoCipherRNView.h"
|
|
10
|
+
|
|
11
|
+
#ifndef RCTVdoPlayerUIView_h
|
|
12
|
+
#define RCTVdoPlayerUIView_h
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#endif /* RCTVdoPlayerUIView_h */
|
|
16
|
+
|
|
17
|
+
@interface RCTVdoPlayerUIView : VdoCipherRNView
|
|
18
|
+
|
|
19
|
+
@end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTVdoPlayerUIView.swift
|
|
3
|
+
// react-native-vdocipher-rn-bridge
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 22/05/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import React
|
|
9
|
+
import Foundation
|
|
10
|
+
import VdoFramework
|
|
11
|
+
|
|
12
|
+
@objc(RCTVdoPlayerUIView)
|
|
13
|
+
class RCTVdoPlayerUIView: VdoCipherRNView {
|
|
14
|
+
|
|
15
|
+
override func setEmbedInfo(_ embedInfo: [String: Any]) {
|
|
16
|
+
super.setEmbedInfo(embedInfo)
|
|
17
|
+
|
|
18
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33 , execute: {
|
|
19
|
+
|
|
20
|
+
EventEmitter.sharedInstance.dispatch(name: EventName.EVENT_LOADING, params: nil)
|
|
21
|
+
|
|
22
|
+
let playerViewController = VdoCipher.getVdoPlayerViewController()
|
|
23
|
+
playerViewController.view.frame = self.bounds
|
|
24
|
+
playerViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
25
|
+
self.reactViewController().addChild(playerViewController)
|
|
26
|
+
self.addSubview(playerViewController.view)
|
|
27
|
+
playerViewController.didMove(toParent: self.reactViewController())
|
|
28
|
+
self.reactViewController().navigationController?.delegate = self
|
|
29
|
+
guard let playbackInfo = embedInfo["playbackInfo"] as? String,
|
|
30
|
+
let otp = embedInfo["otp"] as? String,
|
|
31
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
32
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded) else {
|
|
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
|
|
38
|
+
}
|
|
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
|
+
})
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTVdoPlayerView.h
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 25/05/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "VdoCipherRNView.h"
|
|
9
|
+
|
|
10
|
+
#ifndef RCTVdoPlayerView_h
|
|
11
|
+
#define RCTVdoPlayerView_h
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
#endif /* RCTVdoPlayerView_h */
|
|
15
|
+
|
|
16
|
+
@interface RCTVdoPlayerView : VdoCipherRNView
|
|
17
|
+
|
|
18
|
+
@end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTVdoPlayerView.swift
|
|
3
|
+
// react-native-vdocipher-rn-bridge
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 25/05/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import React
|
|
9
|
+
import Foundation
|
|
10
|
+
import VdoFramework
|
|
11
|
+
import AVKit
|
|
12
|
+
|
|
13
|
+
@objc(RCTVdoPlayerView)
|
|
14
|
+
class RCTVdoPlayerView: VdoCipherRNView {
|
|
15
|
+
|
|
16
|
+
var playerLayer: AVPlayerLayer?
|
|
17
|
+
|
|
18
|
+
override func setEmbedInfo(_ embedInfo: [String: Any]) {
|
|
19
|
+
super.setEmbedInfo(embedInfo)
|
|
20
|
+
EventEmitter.sharedInstance.dispatch(name: EventName.EVENT_LOADING, params: nil)
|
|
21
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.33 , execute: {
|
|
22
|
+
self.reactViewController().navigationController?.delegate = self
|
|
23
|
+
})
|
|
24
|
+
guard let playbackInfo = embedInfo["playbackInfo"] as? String,
|
|
25
|
+
let otp = embedInfo["otp"] as? String,
|
|
26
|
+
let decoded = Data(base64Encoded: playbackInfo),
|
|
27
|
+
let parsed = try? JSONDecoder().decode(PlaybackInfo.self, from: decoded) else {
|
|
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
|
|
33
|
+
}
|
|
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
|
+
}
|
|
67
|
+
|
|
68
|
+
override func playerReadyToPlay() {
|
|
69
|
+
playerLayer = AVPlayerLayer(player: player)
|
|
70
|
+
playerLayer?.frame = self.bounds
|
|
71
|
+
playerLayer?.videoGravity = .resizeAspect
|
|
72
|
+
self.layer.sublayers?
|
|
73
|
+
.filter { $0 is AVPlayerLayer }
|
|
74
|
+
.forEach { $0.removeFromSuperlayer() }
|
|
75
|
+
self.layer.addSublayer(playerLayer!)
|
|
76
|
+
super.playerReadyToPlay()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override func layoutSubviews() {
|
|
80
|
+
super.layoutSubviews()
|
|
81
|
+
self.playerLayer?.frame = self.bounds
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TrackSelection.swift
|
|
3
|
+
// react-native-vdocipher-rn-bridge
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 14/06/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import VdoFramework
|
|
10
|
+
import React
|
|
11
|
+
|
|
12
|
+
@objc(TrackSelection)
|
|
13
|
+
class TrackSelection: NSObject {
|
|
14
|
+
|
|
15
|
+
/// Current Asset
|
|
16
|
+
static var asset: VdoAsset? {
|
|
17
|
+
didSet{
|
|
18
|
+
guard let captions = TrackSelection.asset?.captions else {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
var captionLanguages = [[String: Any]] ()
|
|
22
|
+
var counter = 1
|
|
23
|
+
for caption in captions {
|
|
24
|
+
guard let lang = caption.lang,
|
|
25
|
+
let label = caption.label,
|
|
26
|
+
let name = caption.captionName else {continue}
|
|
27
|
+
captionLanguages.append(["id": counter,
|
|
28
|
+
"language": lang,
|
|
29
|
+
"label": label,
|
|
30
|
+
"name": name])
|
|
31
|
+
counter += 1
|
|
32
|
+
}
|
|
33
|
+
TrackSelection.captionLanguagesMap = captionLanguages
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
static var captionLanguagesMap: [[String: Any]]?
|
|
37
|
+
|
|
38
|
+
@objc func getCaptionLanguages(_ callback: RCTResponseSenderBlock) {
|
|
39
|
+
// print("========= TrackSelection getCaptionLanguages called")
|
|
40
|
+
guard let captionLanguagesMap = TrackSelection.captionLanguagesMap else {
|
|
41
|
+
callback(nil)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
callback([captionLanguagesMap])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@objc func getSelectedCaptionLanguage(_ callback: RCTResponseSenderBlock) {
|
|
48
|
+
// print("========= TrackSelection getSelectedCaptionLanguage called")
|
|
49
|
+
guard let selectedCaption = TrackSelection.asset?.getCurrentEnabledCaption(),
|
|
50
|
+
let name = selectedCaption.captionName,
|
|
51
|
+
let selectedCaptionMap = TrackSelection.captionLanguagesMap?.first(where: {$0["name"] as? String == name}) else {
|
|
52
|
+
callback([])
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
// print("Selected Caption Map is \(selectedCaptionMap)")
|
|
56
|
+
callback([selectedCaptionMap])
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@objc func getDuration(_ callback: RCTResponseSenderBlock) {
|
|
60
|
+
// print("========= TrackSelection getDuration called")
|
|
61
|
+
guard let duration = TrackSelection.asset?.duration else {return}
|
|
62
|
+
callback([["duration": duration]])
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VdoCipherRNView.h
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Manish Gupta on 31/05/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#ifndef VdoCipherRNView_h
|
|
9
|
+
#define VdoCipherRNView_h
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#endif /* VdoCipherRNView_h */
|
|
13
|
+
|
|
14
|
+
#import <VdoFramework/VdoFramework.h>
|
|
15
|
+
|
|
16
|
+
@interface VdoCipherRNView: UIView
|
|
17
|
+
|
|
18
|
+
@end
|