Skip to content

Commit ea7a7bb

Browse files
author
Brent Vatne
committed
Initial commit
0 parents  commit ea7a7bb

12 files changed

Lines changed: 471 additions & 0 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/**/*
2+
RCTVideo.xcodeproj/xcuserdata/**/*
3+
RCTVideo.xcodeproj/project.xcworkspace/**/*

RCTVideo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <UIKit/UIKit.h>
2+
3+
@interface RCTVideo : UIView
4+
5+
@end

RCTVideo.m

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#import "RCTVideo.h"
2+
#import "RCTLog.h"
3+
4+
@import MediaPlayer;
5+
6+
@implementation RCTVideo
7+
{
8+
MPMoviePlayerController *_player;
9+
}
10+
11+
- (id)init
12+
{
13+
if ((self = [super init])) {
14+
_player = [[MPMoviePlayerController alloc] init];
15+
[self addSubview: _player.view];
16+
}
17+
return self;
18+
}
19+
20+
- (void)setSrc:(NSString *)source
21+
{
22+
NSURL *videoURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:source ofType:@"mp4"]];
23+
[_player setContentURL:videoURL];
24+
[_player setControlStyle:MPMovieControlStyleNone];
25+
[_player setScalingMode:MPMovieScalingModeNone];
26+
[_player setRepeatMode:MPMovieRepeatModeOne];
27+
[_player prepareToPlay];
28+
[_player play];
29+
}
30+
31+
- (void)setResizeMode:(NSInteger)mode
32+
{
33+
[_player setScalingMode:mode];
34+
}
35+
36+
- (NSArray *)reactSubviews
37+
{
38+
NSArray *subviews = @[_player.view];
39+
return subviews;
40+
}
41+
42+
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
43+
{
44+
RCTLogError(@"video cannot have any subviews");
45+
return;
46+
}
47+
48+
- (void)removeReactSubview:(UIView *)subview
49+
{
50+
RCTLogError(@"video cannot have any subviews");
51+
return;
52+
}
53+
54+
- (void)layoutSubviews
55+
{
56+
[super layoutSubviews];
57+
_player.view.frame = self.bounds;
58+
}
59+
60+
@end

RCTVideo.xcodeproj/project.pbxproj

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */; };
11+
BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */; };
12+
/* End PBXBuildFile section */
13+
14+
/* Begin PBXCopyFilesBuildPhase section */
15+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
16+
isa = PBXCopyFilesBuildPhase;
17+
buildActionMask = 2147483647;
18+
dstPath = "include/$(PRODUCT_NAME)";
19+
dstSubfolderSpec = 16;
20+
files = (
21+
);
22+
runOnlyForDeploymentPostprocessing = 0;
23+
};
24+
/* End PBXCopyFilesBuildPhase section */
25+
26+
/* Begin PBXFileReference section */
27+
134814201AA4EA6300B7C361 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVideo.a; sourceTree = BUILT_PRODUCTS_DIR; };
28+
BBD49E391AC8DEF000610F8E /* RCTVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideo.h; sourceTree = "<group>"; };
29+
BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideo.m; sourceTree = "<group>"; };
30+
BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVideoManager.h; sourceTree = "<group>"; };
31+
BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVideoManager.m; sourceTree = "<group>"; };
32+
/* End PBXFileReference section */
33+
34+
/* Begin PBXFrameworksBuildPhase section */
35+
58B511D81A9E6C8500147676 /* Frameworks */ = {
36+
isa = PBXFrameworksBuildPhase;
37+
buildActionMask = 2147483647;
38+
files = (
39+
);
40+
runOnlyForDeploymentPostprocessing = 0;
41+
};
42+
/* End PBXFrameworksBuildPhase section */
43+
44+
/* Begin PBXGroup section */
45+
134814211AA4EA7D00B7C361 /* Products */ = {
46+
isa = PBXGroup;
47+
children = (
48+
134814201AA4EA6300B7C361 /* libRCTVideo.a */,
49+
);
50+
name = Products;
51+
sourceTree = "<group>";
52+
};
53+
58B511D21A9E6C8500147676 = {
54+
isa = PBXGroup;
55+
children = (
56+
BBD49E391AC8DEF000610F8E /* RCTVideo.h */,
57+
BBD49E3A1AC8DEF000610F8E /* RCTVideo.m */,
58+
BBD49E3B1AC8DEF000610F8E /* RCTVideoManager.h */,
59+
BBD49E3C1AC8DEF000610F8E /* RCTVideoManager.m */,
60+
134814211AA4EA7D00B7C361 /* Products */,
61+
);
62+
sourceTree = "<group>";
63+
};
64+
/* End PBXGroup section */
65+
66+
/* Begin PBXNativeTarget section */
67+
58B511DA1A9E6C8500147676 /* RCTVideo */ = {
68+
isa = PBXNativeTarget;
69+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTVideo" */;
70+
buildPhases = (
71+
58B511D71A9E6C8500147676 /* Sources */,
72+
58B511D81A9E6C8500147676 /* Frameworks */,
73+
58B511D91A9E6C8500147676 /* CopyFiles */,
74+
);
75+
buildRules = (
76+
);
77+
dependencies = (
78+
);
79+
name = RCTVideo;
80+
productName = RCTDataManager;
81+
productReference = 134814201AA4EA6300B7C361 /* libRCTVideo.a */;
82+
productType = "com.apple.product-type.library.static";
83+
};
84+
/* End PBXNativeTarget section */
85+
86+
/* Begin PBXProject section */
87+
58B511D31A9E6C8500147676 /* Project object */ = {
88+
isa = PBXProject;
89+
attributes = {
90+
LastUpgradeCheck = 0610;
91+
ORGANIZATIONNAME = Facebook;
92+
TargetAttributes = {
93+
58B511DA1A9E6C8500147676 = {
94+
CreatedOnToolsVersion = 6.1.1;
95+
};
96+
};
97+
};
98+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTVideo" */;
99+
compatibilityVersion = "Xcode 3.2";
100+
developmentRegion = English;
101+
hasScannedForEncodings = 0;
102+
knownRegions = (
103+
en,
104+
);
105+
mainGroup = 58B511D21A9E6C8500147676;
106+
productRefGroup = 58B511D21A9E6C8500147676;
107+
projectDirPath = "";
108+
projectRoot = "";
109+
targets = (
110+
58B511DA1A9E6C8500147676 /* RCTVideo */,
111+
);
112+
};
113+
/* End PBXProject section */
114+
115+
/* Begin PBXSourcesBuildPhase section */
116+
58B511D71A9E6C8500147676 /* Sources */ = {
117+
isa = PBXSourcesBuildPhase;
118+
buildActionMask = 2147483647;
119+
files = (
120+
BBD49E3F1AC8DEF000610F8E /* RCTVideo.m in Sources */,
121+
BBD49E401AC8DEF000610F8E /* RCTVideoManager.m in Sources */,
122+
);
123+
runOnlyForDeploymentPostprocessing = 0;
124+
};
125+
/* End PBXSourcesBuildPhase section */
126+
127+
/* Begin XCBuildConfiguration section */
128+
58B511ED1A9E6C8500147676 /* Debug */ = {
129+
isa = XCBuildConfiguration;
130+
buildSettings = {
131+
ALWAYS_SEARCH_USER_PATHS = NO;
132+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
133+
CLANG_CXX_LIBRARY = "libc++";
134+
CLANG_ENABLE_MODULES = YES;
135+
CLANG_ENABLE_OBJC_ARC = YES;
136+
CLANG_WARN_BOOL_CONVERSION = YES;
137+
CLANG_WARN_CONSTANT_CONVERSION = YES;
138+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
139+
CLANG_WARN_EMPTY_BODY = YES;
140+
CLANG_WARN_ENUM_CONVERSION = YES;
141+
CLANG_WARN_INT_CONVERSION = YES;
142+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
143+
CLANG_WARN_UNREACHABLE_CODE = YES;
144+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
145+
COPY_PHASE_STRIP = NO;
146+
ENABLE_STRICT_OBJC_MSGSEND = YES;
147+
GCC_C_LANGUAGE_STANDARD = gnu99;
148+
GCC_DYNAMIC_NO_PIC = NO;
149+
GCC_OPTIMIZATION_LEVEL = 0;
150+
GCC_PREPROCESSOR_DEFINITIONS = (
151+
"DEBUG=1",
152+
"$(inherited)",
153+
);
154+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
155+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
156+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
157+
GCC_WARN_UNDECLARED_SELECTOR = YES;
158+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
159+
GCC_WARN_UNUSED_FUNCTION = YES;
160+
GCC_WARN_UNUSED_VARIABLE = YES;
161+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
162+
MTL_ENABLE_DEBUG_INFO = YES;
163+
ONLY_ACTIVE_ARCH = YES;
164+
SDKROOT = iphoneos;
165+
};
166+
name = Debug;
167+
};
168+
58B511EE1A9E6C8500147676 /* Release */ = {
169+
isa = XCBuildConfiguration;
170+
buildSettings = {
171+
ALWAYS_SEARCH_USER_PATHS = NO;
172+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
173+
CLANG_CXX_LIBRARY = "libc++";
174+
CLANG_ENABLE_MODULES = YES;
175+
CLANG_ENABLE_OBJC_ARC = YES;
176+
CLANG_WARN_BOOL_CONVERSION = YES;
177+
CLANG_WARN_CONSTANT_CONVERSION = YES;
178+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
179+
CLANG_WARN_EMPTY_BODY = YES;
180+
CLANG_WARN_ENUM_CONVERSION = YES;
181+
CLANG_WARN_INT_CONVERSION = YES;
182+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
183+
CLANG_WARN_UNREACHABLE_CODE = YES;
184+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
185+
COPY_PHASE_STRIP = YES;
186+
ENABLE_NS_ASSERTIONS = NO;
187+
ENABLE_STRICT_OBJC_MSGSEND = YES;
188+
GCC_C_LANGUAGE_STANDARD = gnu99;
189+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
190+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
191+
GCC_WARN_UNDECLARED_SELECTOR = YES;
192+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
193+
GCC_WARN_UNUSED_FUNCTION = YES;
194+
GCC_WARN_UNUSED_VARIABLE = YES;
195+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
196+
MTL_ENABLE_DEBUG_INFO = NO;
197+
SDKROOT = iphoneos;
198+
VALIDATE_PRODUCT = YES;
199+
};
200+
name = Release;
201+
};
202+
58B511F01A9E6C8500147676 /* Debug */ = {
203+
isa = XCBuildConfiguration;
204+
buildSettings = {
205+
HEADER_SEARCH_PATHS = (
206+
"$(inherited)",
207+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
208+
"$(SRCROOT)/node_modules/react-native/React/**",
209+
);
210+
LIBRARY_SEARCH_PATHS = "$(inherited)";
211+
OTHER_LDFLAGS = "-ObjC";
212+
PRODUCT_NAME = RCTVideo;
213+
SKIP_INSTALL = YES;
214+
};
215+
name = Debug;
216+
};
217+
58B511F11A9E6C8500147676 /* Release */ = {
218+
isa = XCBuildConfiguration;
219+
buildSettings = {
220+
HEADER_SEARCH_PATHS = (
221+
"$(inherited)",
222+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
223+
"$(SRCROOT)/node_modules/react-native/React/**",
224+
);
225+
LIBRARY_SEARCH_PATHS = "$(inherited)";
226+
OTHER_LDFLAGS = "-ObjC";
227+
PRODUCT_NAME = RCTVideo;
228+
SKIP_INSTALL = YES;
229+
};
230+
name = Release;
231+
};
232+
/* End XCBuildConfiguration section */
233+
234+
/* Begin XCConfigurationList section */
235+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTVideo" */ = {
236+
isa = XCConfigurationList;
237+
buildConfigurations = (
238+
58B511ED1A9E6C8500147676 /* Debug */,
239+
58B511EE1A9E6C8500147676 /* Release */,
240+
);
241+
defaultConfigurationIsVisible = 0;
242+
defaultConfigurationName = Release;
243+
};
244+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTVideo" */ = {
245+
isa = XCConfigurationList;
246+
buildConfigurations = (
247+
58B511F01A9E6C8500147676 /* Debug */,
248+
58B511F11A9E6C8500147676 /* Release */,
249+
);
250+
defaultConfigurationIsVisible = 0;
251+
defaultConfigurationName = Release;
252+
};
253+
/* End XCConfigurationList section */
254+
};
255+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
256+
}

RCTVideoManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import "RCTViewManager.h"
2+
3+
@interface RCTVideoManager : RCTViewManager
4+
5+
@end

RCTVideoManager.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#import "RCTVideoManager.h"
2+
#import "RCTVideo.h"
3+
#import "RCTBridge.h"
4+
@import MediaPlayer;
5+
6+
@implementation RCTVideoManager
7+
8+
@synthesize bridge = _bridge;
9+
10+
- (UIView *)view
11+
{
12+
return [[RCTVideo alloc] init];
13+
}
14+
15+
RCT_EXPORT_VIEW_PROPERTY(src, NSString);
16+
RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSInteger);
17+
18+
- (NSDictionary *)constantsToExport
19+
{
20+
return @{@"ScaleNone": @(MPMovieScalingModeNone),
21+
@"ScaleToFill": @(MPMovieScalingModeFill),
22+
@"ScaleAspectFit": @(MPMovieScalingModeAspectFit),
23+
@"ScaleAspectFill": @(MPMovieScalingModeAspectFill)};
24+
}
25+
26+
@end

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## react-native-video
2+
3+
A <Video> component for react-native, as seen in
4+
[react-native-login](https://github.com/brentvatne/react-native-login).

Video.android.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
var warning = require('warning');
4+
5+
var Video = {
6+
test: function() {
7+
warning("Not yet implemented for Android.");
8+
}
9+
};
10+
11+
module.exports = Video;

0 commit comments

Comments
 (0)