Skip to content

Commit

Permalink
VEX-5682: iOS Swift Conversion (#11)
Browse files Browse the repository at this point in the history
Converts ios implementation from objective-c to swift.
  • Loading branch information
nickfujita authored Oct 27, 2021
1 parent 3bcf2c6 commit 8b75438
Show file tree
Hide file tree
Showing 34 changed files with 2,659 additions and 2,311 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ project.xcworkspace
.gradle
local.properties
*.hprof
.project
.settings
.classpath

# node.js
#
Expand Down
23 changes: 15 additions & 8 deletions examples/basic/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,11 @@ ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"

eme-encryption-scheme-polyfill@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.0.3.tgz#2ca6e06480e06cceb5e50efd27943ac46c959878"
integrity sha512-44CNFMsqzHdKHrzWxlS7xZ8KUHn5XutBqpmCuWzNIynmAyFInHrrD3ozv/RvK9ZhgV6QY6Easx8EWAmxteNodg==

emoji-regex@^7.0.1:
version "7.0.3"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
Expand Down Expand Up @@ -5160,7 +5165,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.3"

prop-types@^15.5.10, prop-types@^15.6.2, prop-types@^15.7.2:
prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -5238,11 +5243,11 @@ react-is@^16.8.4, react-is@^16.8.6:
integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==

"react-native-video@file:../..":
version "5.0.1"
version "5.1.1"
dependencies:
keymirror "^0.1.1"
prop-types "^15.5.10"
shaka-player "^2.4.4"
prop-types "^15.7.2"
shaka-player "^2.5.9"

react-native@0.60.5:
version "0.60.5"
Expand Down Expand Up @@ -5774,10 +5779,12 @@ setprototypeof@1.1.1:
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683"
integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==

shaka-player@^2.4.4:
version "2.5.2"
resolved "https://registry.yarnpkg.com/shaka-player/-/shaka-player-2.5.2.tgz#3e639f8f5dfdb1a0afff2ff1f87cddf481f93fe4"
integrity sha512-gpRfXVLAZi33kw9Egop18MkZ/EVRS0soeN6ocR+Btq/J5IoCC56MxwwHzAGna+PgBW9Ox458HRefJ6HB0BoADA==
shaka-player@^2.5.9:
version "2.5.23"
resolved "https://registry.yarnpkg.com/shaka-player/-/shaka-player-2.5.23.tgz#db92d1c6cf2314f0180a2cec11b0e2f2560336f5"
integrity sha512-3MC9k0OXJGw8AZ4n/ZNCZS2yDxx+3as5KgH6Tx4Q5TRboTBBCu6dYPI5vp1DxKeyU12MBN1Zcbs7AKzXv2EnCg==
dependencies:
eme-encryption-scheme-polyfill "^2.0.1"

shebang-command@^1.2.0:
version "1.2.0"
Expand Down
91 changes: 54 additions & 37 deletions ios/RCTVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
objects = {

/* Begin PBXBuildFile section */
D1107C0A2110259000073188 /* UIView+FindUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C032110259000073188 /* UIView+FindUIViewController.m */; };
D1107C0B2110259000073188 /* UIView+FindUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C032110259000073188 /* UIView+FindUIViewController.m */; };
D1107C0C2110259000073188 /* RCTVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C052110259000073188 /* RCTVideo.m */; };
D1107C0D2110259000073188 /* RCTVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C052110259000073188 /* RCTVideo.m */; };
D1107C0E2110259000073188 /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C062110259000073188 /* RCTVideoManager.m */; };
D1107C0F2110259000073188 /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C062110259000073188 /* RCTVideoManager.m */; };
D1107C102110259000073188 /* RCTVideoPlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C082110259000073188 /* RCTVideoPlayerViewController.m */; };
D1107C112110259000073188 /* RCTVideoPlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D1107C082110259000073188 /* RCTVideoPlayerViewController.m */; };
0177D39A27170A7A00F5BE18 /* RCTVideoManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39227170A7A00F5BE18 /* RCTVideoManager.swift */; };
0177D39B27170A7A00F5BE18 /* UIView+FindUIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39327170A7A00F5BE18 /* UIView+FindUIViewController.swift */; };
0177D39C27170A7A00F5BE18 /* RCTVideoPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39427170A7A00F5BE18 /* RCTVideoPlayerViewController.swift */; };
0177D39D27170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39627170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift */; };
0177D39E27170A7A00F5BE18 /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39727170A7A00F5BE18 /* RCTVideoManager.m */; };
0177D39F27170A7A00F5BE18 /* RCTVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0177D39927170A7A00F5BE18 /* RCTVideo.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -39,17 +37,18 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
01450CB5271D5738005D8F6B /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; };
01489050272001A100E69940 /* DataStructures */ = {isa = PBXFileReference; lastKnownFileType = folder; name = DataStructures; path = Video/DataStructures; sourceTree = "<group>"; };
01489051272001A100E69940 /* Features */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Features; path = Video/Features; sourceTree = "<group>"; };
0177D39227170A7A00F5BE18 /* RCTVideoManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RCTVideoManager.swift; path = Video/RCTVideoManager.swift; sourceTree = "<group>"; };
0177D39327170A7A00F5BE18 /* UIView+FindUIViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+FindUIViewController.swift"; path = "Video/UIView+FindUIViewController.swift"; sourceTree = "<group>"; };
0177D39427170A7A00F5BE18 /* RCTVideoPlayerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RCTVideoPlayerViewController.swift; path = Video/RCTVideoPlayerViewController.swift; sourceTree = "<group>"; };
0177D39527170A7A00F5BE18 /* RCTSwiftLog */ = {isa = PBXFileReference; lastKnownFileType = folder; name = RCTSwiftLog; path = Video/RCTSwiftLog; sourceTree = "<group>"; };
0177D39627170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RCTVideoPlayerViewControllerDelegate.swift; path = Video/RCTVideoPlayerViewControllerDelegate.swift; sourceTree = "<group>"; };
0177D39727170A7A00F5BE18 /* RCTVideoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTVideoManager.m; path = Video/RCTVideoManager.m; sourceTree = "<group>"; };
0177D39827170A7A00F5BE18 /* RCTVideo-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RCTVideo-Bridging-Header.h"; path = "Video/RCTVideo-Bridging-Header.h"; sourceTree = "<group>"; };
0177D39927170A7A00F5BE18 /* RCTVideo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RCTVideo.swift; path = Video/RCTVideo.swift; sourceTree = "<group>"; };
134814201AA4EA6300B7C361 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; };
641E28441F0EEC8500443AF6 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; };
D1107C012110259000073188 /* RCTVideoPlayerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTVideoPlayerViewController.h; path = Video/RCTVideoPlayerViewController.h; sourceTree = "<group>"; };
D1107C022110259000073188 /* RCTVideoPlayerViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTVideoPlayerViewControllerDelegate.h; path = Video/RCTVideoPlayerViewControllerDelegate.h; sourceTree = "<group>"; };
D1107C032110259000073188 /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+FindUIViewController.m"; path = "Video/UIView+FindUIViewController.m"; sourceTree = "<group>"; };
D1107C042110259000073188 /* UIView+FindUIViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+FindUIViewController.h"; path = "Video/UIView+FindUIViewController.h"; sourceTree = "<group>"; };
D1107C052110259000073188 /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTVideo.m; path = Video/RCTVideo.m; sourceTree = "<group>"; };
D1107C062110259000073188 /* RCTVideoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTVideoManager.m; path = Video/RCTVideoManager.m; sourceTree = "<group>"; };
D1107C072110259000073188 /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTVideo.h; path = Video/RCTVideo.h; sourceTree = "<group>"; };
D1107C082110259000073188 /* RCTVideoPlayerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTVideoPlayerViewController.m; path = Video/RCTVideoPlayerViewController.m; sourceTree = "<group>"; };
D1107C092110259000073188 /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTVideoManager.h; path = Video/RCTVideoManager.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -88,18 +87,19 @@
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
D1107C072110259000073188 /* RCTVideo.h */,
D1107C052110259000073188 /* RCTVideo.m */,
D1107C092110259000073188 /* RCTVideoManager.h */,
D1107C062110259000073188 /* RCTVideoManager.m */,
D1107C012110259000073188 /* RCTVideoPlayerViewController.h */,
D1107C082110259000073188 /* RCTVideoPlayerViewController.m */,
D1107C022110259000073188 /* RCTVideoPlayerViewControllerDelegate.h */,
D1107C042110259000073188 /* UIView+FindUIViewController.h */,
D1107C032110259000073188 /* UIView+FindUIViewController.m */,
01489050272001A100E69940 /* DataStructures */,
01489051272001A100E69940 /* Features */,
0177D39527170A7A00F5BE18 /* RCTSwiftLog */,
0177D39927170A7A00F5BE18 /* RCTVideo.swift */,
0177D39727170A7A00F5BE18 /* RCTVideoManager.m */,
0177D39227170A7A00F5BE18 /* RCTVideoManager.swift */,
0177D39427170A7A00F5BE18 /* RCTVideoPlayerViewController.swift */,
0177D39627170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift */,
0177D39327170A7A00F5BE18 /* UIView+FindUIViewController.swift */,
0177D39827170A7A00F5BE18 /* RCTVideo-Bridging-Header.h */,
134814211AA4EA7D00B7C361 /* Products */,
641E28441F0EEC8500443AF6 /* libRCTVideo.a */,
49E995712048B4CE00EA7890 /* Frameworks */,
01450CB5271D5738005D8F6B /* libRCTVideo.a */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -137,7 +137,7 @@
);
name = "RCTVideo-tvOS";
productName = "RCTVideo-tvOS";
productReference = 641E28441F0EEC8500443AF6 /* libRCTVideo.a */;
productReference = 01450CB5271D5738005D8F6B /* libRCTVideo.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
Expand All @@ -151,9 +151,11 @@
TargetAttributes = {
58B511DA1A9E6C8500147676 = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 1300;
};
641E28431F0EEC8500443AF6 = {
CreatedOnToolsVersion = 8.3.3;
LastSwiftMigration = 1300;
ProvisioningStyle = Automatic;
};
};
Expand All @@ -163,6 +165,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 58B511D21A9E6C8500147676;
Expand All @@ -181,21 +184,19 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D1107C0A2110259000073188 /* UIView+FindUIViewController.m in Sources */,
D1107C102110259000073188 /* RCTVideoPlayerViewController.m in Sources */,
D1107C0E2110259000073188 /* RCTVideoManager.m in Sources */,
D1107C0C2110259000073188 /* RCTVideo.m in Sources */,
0177D39D27170A7A00F5BE18 /* RCTVideoPlayerViewControllerDelegate.swift in Sources */,
0177D39C27170A7A00F5BE18 /* RCTVideoPlayerViewController.swift in Sources */,
0177D39B27170A7A00F5BE18 /* UIView+FindUIViewController.swift in Sources */,
0177D39F27170A7A00F5BE18 /* RCTVideo.swift in Sources */,
0177D39E27170A7A00F5BE18 /* RCTVideoManager.m in Sources */,
0177D39A27170A7A00F5BE18 /* RCTVideoManager.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
641E28401F0EEC8500443AF6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D1107C0B2110259000073188 /* UIView+FindUIViewController.m in Sources */,
D1107C112110259000073188 /* RCTVideoPlayerViewController.m in Sources */,
D1107C0F2110259000073188 /* RCTVideoManager.m in Sources */,
D1107C0D2110259000073188 /* RCTVideo.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -280,30 +281,39 @@
58B511F01A9E6C8500147676 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/Vendor/SPTPersistentCache/include/**",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RCTVideo;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Video/RCTVideo-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
58B511F11A9E6C8500147676 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/Vendor/SPTPersistentCache/include/**",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RCTVideo;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Video/RCTVideo-Bridging-Header.h";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -312,15 +322,19 @@
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RCTVideo;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 10.2;
};
name = Debug;
Expand All @@ -330,16 +344,19 @@
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RCTVideo;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 10.2;
};
name = Release;
Expand Down
30 changes: 30 additions & 0 deletions ios/Video/DataStructures/DRMParams.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
struct DRMParams {
let type: String?
let licenseServer: String?
let headers: Dictionary<String,Any>?
let contentId: String?
let certificateUrl: String?
let base64Certificate: Bool?

let json: NSDictionary?

init(_ json: NSDictionary!) {
guard json != nil else {
self.json = nil
self.type = nil
self.licenseServer = nil
self.contentId = nil
self.certificateUrl = nil
self.base64Certificate = nil
self.headers = nil
return
}
self.json = json
self.type = json["type"] as? String
self.licenseServer = json["licenseServer"] as? String
self.contentId = json["contentId"] as? String
self.certificateUrl = json["certificateUrl"] as? String
self.base64Certificate = json["base64Certificate"] as? Bool
self.headers = json["headers"] as? Dictionary<String,Any>
}
}
18 changes: 18 additions & 0 deletions ios/Video/DataStructures/SelectedTrackCriteria.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
struct SelectedTrackCriteria {
let type: String
let value: Any?

let json: NSDictionary?

init(_ json: NSDictionary!) {
guard json != nil else {
self.json = nil
self.type = ""
self.value = nil
return
}
self.json = json
self.type = json["type"] as? String ?? ""
self.value = json["value"]
}
}
25 changes: 25 additions & 0 deletions ios/Video/DataStructures/TextTrack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

struct TextTrack {
let type: String
let language: String
let title: String
let uri: String

let json: NSDictionary?

init(_ json: NSDictionary!) {
guard json != nil else {
self.json = nil
self.type = ""
self.language = ""
self.title = ""
self.uri = ""
return
}
self.json = json
self.type = json["type"] as? String ?? ""
self.language = json["language"] as? String ?? ""
self.title = json["title"] as? String ?? ""
self.uri = json["uri"] as? String ?? ""
}
}
31 changes: 31 additions & 0 deletions ios/Video/DataStructures/VideoSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

struct VideoSource {
let type: String?
let uri: String?
let isNetwork: Bool
let isAsset: Bool
let shouldCache: Bool
let requestHeaders: Dictionary<String,Any>?

let json: NSDictionary?

init(_ json: NSDictionary!) {
guard json != nil else {
self.json = nil
self.type = nil
self.uri = nil
self.isNetwork = false
self.isAsset = false
self.shouldCache = false
self.requestHeaders = nil
return
}
self.json = json
self.type = json["type"] as? String
self.uri = json["uri"] as? String
self.isNetwork = json["isNetwork"] as? Bool ?? false
self.isAsset = json["isAsset"] as? Bool ?? false
self.shouldCache = json["shouldCache"] as? Bool ?? false
self.requestHeaders = json["requestHeaders"] as? Dictionary<String,Any>
}
}
Loading

0 comments on commit 8b75438

Please sign in to comment.