[Android] Fix require(...)
file resource on production (#429)
* Fix require(...) file resource on Android production * Update example (use require for ./broadchurch.mp4) * Fix MainApplication.java of example * Add default source type
This commit is contained in:
parent
201335f05c
commit
d450afc83b
@ -84,10 +84,17 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int identifier = context.getResources().getIdentifier(
|
int identifier = context.getResources().getIdentifier(
|
||||||
|
uriString,
|
||||||
|
"drawable",
|
||||||
|
context.getPackageName()
|
||||||
|
);
|
||||||
|
if (identifier == 0) {
|
||||||
|
identifier = context.getResources().getIdentifier(
|
||||||
uriString,
|
uriString,
|
||||||
"raw",
|
"raw",
|
||||||
context.getPackageName()
|
context.getPackageName()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
if (identifier > 0) {
|
if (identifier > 0) {
|
||||||
Uri srcUri = RawResourceDataSource.buildRawResourceUri(identifier);
|
Uri srcUri = RawResourceDataSource.buildRawResourceUri(identifier);
|
||||||
if (srcUri != null) {
|
if (srcUri != null) {
|
||||||
|
@ -258,11 +258,19 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fd==null) {
|
if(fd==null) {
|
||||||
setRawData(mThemedReactContext.getResources().getIdentifier(
|
int identifier = mThemedReactContext.getResources().getIdentifier(
|
||||||
|
uriString,
|
||||||
|
"drawable",
|
||||||
|
mThemedReactContext.getPackageName()
|
||||||
|
);
|
||||||
|
if (identifier == 0) {
|
||||||
|
identifier = mThemedReactContext.getResources().getIdentifier(
|
||||||
uriString,
|
uriString,
|
||||||
"raw",
|
"raw",
|
||||||
mThemedReactContext.getPackageName()
|
mThemedReactContext.getPackageName()
|
||||||
));
|
);
|
||||||
|
}
|
||||||
|
setRawData(identifier);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setDataSource(fd.getFileDescriptor(), fd.getStartOffset(),fd.getLength());
|
setDataSource(fd.getFileDescriptor(), fd.getStartOffset(),fd.getLength());
|
||||||
|
@ -14,27 +14,17 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MainApplication extends Application implements ReactApplication {
|
public class MainApplication extends Application implements ReactApplication {
|
||||||
|
|
||||||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean getUseDeveloperSupport() {
|
public boolean getUseDeveloperSupport() {
|
||||||
return BuildConfig.DEBUG;
|
return BuildConfig.DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<ReactPackage> getPackages() {
|
|
||||||
return Arrays.asList(
|
|
||||||
new MainReactPackage(),
|
|
||||||
new ReactVideoPackage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
protected List<ReactPackage> getPackages() {
|
protected List<ReactPackage> getPackages() {
|
||||||
return Arrays.<ReactPackage>asList(
|
return Arrays.asList(
|
||||||
new MainReactPackage(),
|
new MainReactPackage(),
|
||||||
new ReactVideoPackage()
|
new ReactVideoPackage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Binary file not shown.
@ -105,9 +105,8 @@ class VideoPlayer extends Component {
|
|||||||
<Video
|
<Video
|
||||||
ref={(ref: Video) => { this.video = ref }}
|
ref={(ref: Video) => { this.video = ref }}
|
||||||
/* For ExoPlayer */
|
/* For ExoPlayer */
|
||||||
/* source={require('./broadchurch.mp4')} */
|
|
||||||
/* source={{ uri: 'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0', type: 'mpd' }} */
|
/* source={{ uri: 'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0', type: 'mpd' }} */
|
||||||
source={{ uri: 'broadchurch', type: 'mp4' }}
|
source={require('./broadchurch.mp4')}
|
||||||
style={styles.fullScreen}
|
style={styles.fullScreen}
|
||||||
rate={this.state.rate}
|
rate={this.state.rate}
|
||||||
paused={this.state.paused}
|
paused={this.state.paused}
|
||||||
|
@ -114,7 +114,7 @@ class VideoPlayer extends Component {
|
|||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<TouchableOpacity style={styles.fullScreen} onPress={() => {this.setState({paused: !this.state.paused})}}>
|
<TouchableOpacity style={styles.fullScreen} onPress={() => {this.setState({paused: !this.state.paused})}}>
|
||||||
<Video
|
<Video
|
||||||
source={{uri: "broadchurch"}}
|
source={require('./broadchurch.mp4')}
|
||||||
style={styles.fullScreen}
|
style={styles.fullScreen}
|
||||||
rate={this.state.rate}
|
rate={this.state.rate}
|
||||||
paused={this.state.paused}
|
paused={this.state.paused}
|
||||||
@ -174,7 +174,7 @@ class VideoPlayer extends Component {
|
|||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.fullScreen}>
|
<View style={styles.fullScreen}>
|
||||||
<Video
|
<Video
|
||||||
source={{uri: "broadchurch"}}
|
source={require('./broadchurch.mp4')}
|
||||||
style={videoStyle}
|
style={videoStyle}
|
||||||
rate={this.state.rate}
|
rate={this.state.rate}
|
||||||
paused={this.state.paused}
|
paused={this.state.paused}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
|
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
|
||||||
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
|
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
|
||||||
8C2A0F841E2560A100E31596 /* libRCTVideo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C2A0F791E25608300E31596 /* libRCTVideo.a */; };
|
8C2A0F841E2560A100E31596 /* libRCTVideo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C2A0F791E25608300E31596 /* libRCTVideo.a */; };
|
||||||
8C2A0F861E25610700E31596 /* broadchurch.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 8C2A0F851E25610200E31596 /* broadchurch.mp4 */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -244,7 +243,6 @@
|
|||||||
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
|
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
|
||||||
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
|
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
|
||||||
8C2A0F651E25608300E31596 /* RCTVideo.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVideo.xcodeproj; path = "../node_modules/react-native-video/ios/RCTVideo.xcodeproj"; sourceTree = "<group>"; };
|
8C2A0F651E25608300E31596 /* RCTVideo.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVideo.xcodeproj; path = "../node_modules/react-native-video/ios/RCTVideo.xcodeproj"; sourceTree = "<group>"; };
|
||||||
8C2A0F851E25610200E31596 /* broadchurch.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; name = broadchurch.mp4; path = ../broadchurch.mp4; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -433,7 +431,6 @@
|
|||||||
83CBB9F61A601CBA00E9B192 = {
|
83CBB9F61A601CBA00E9B192 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
8C2A0F851E25610200E31596 /* broadchurch.mp4 */,
|
|
||||||
13B07FAE1A68108700A75B9A /* VideoPlayer */,
|
13B07FAE1A68108700A75B9A /* VideoPlayer */,
|
||||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||||
00E356EF1AD99517003FC87E /* VideoPlayerTests */,
|
00E356EF1AD99517003FC87E /* VideoPlayerTests */,
|
||||||
@ -782,7 +779,6 @@
|
|||||||
files = (
|
files = (
|
||||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
||||||
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
|
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
|
||||||
8C2A0F861E25610700E31596 /* broadchurch.mp4 in Resources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -802,7 +798,6 @@
|
|||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
|
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
|
||||||
showEnvVarsInLog = 1;
|
|
||||||
};
|
};
|
||||||
/* End PBXShellScriptBuildPhase section */
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
@ -882,10 +877,8 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEAD_CODE_STRIPPING = NO;
|
DEAD_CODE_STRIPPING = NO;
|
||||||
|
|
||||||
INFOPLIST_FILE = VideoPlayer/Info.plist;
|
INFOPLIST_FILE = VideoPlayer/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
|
||||||
OTHER_LDFLAGS = (
|
OTHER_LDFLAGS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"-ObjC",
|
"-ObjC",
|
||||||
@ -901,10 +894,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
|
||||||
INFOPLIST_FILE = VideoPlayer/Info.plist;
|
INFOPLIST_FILE = VideoPlayer/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
|
||||||
OTHER_LDFLAGS = (
|
OTHER_LDFLAGS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"-ObjC",
|
"-ObjC",
|
||||||
@ -984,7 +975,6 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
Loading…
Reference in New Issue
Block a user