React-native-video [android] Undefined Is Not An Object (evaluating Nativemoduels.uimanager.rctvideo.constants')
I integrated react native to an existing android app, I am trying to use react-native-video component for displaying video on the application. React-native: 0.42.0 react-native-vi
Solution 1:
Fixed adding the ReactVideoPackage when creating the ReactInstanceManager
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(newMainReactPackage())
.addPackage(newReactVideoPackage())//<-- this line fixed
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
Solution 2:
cd ios and pod install and again link library
import React, {Component} from'react';
import {
View,
Button,
Text,
Platform,
StyleSheet,
TouchableOpacity,
TouchableHighlight,
Animated,
ScrollView,
Image,
} from'react-native';
import Video from'react-native-video';
export defaultclassAppextendsComponent {
render() {
return (
<View style={{flex: 1, marginTop: 50}}>
<Video
source={{uri: 'YOUR_URL'}} // Can be a URL or a local file.ref={ref => {
this.player = ref;
}} // Store reference
onBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo}
/>
</View>
);
}
}
const styles = StyleSheet.create({
field: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
paddingTop: 10,
paddingBottom:10,
},
backgroundVideo: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
});
Note react-native link react-native-video
Post a Comment for "React-native-video [android] Undefined Is Not An Object (evaluating Nativemoduels.uimanager.rctvideo.constants')"