I would like to use react-native-video in my app. However, what I've done doesn't work :
I created a new project using expo init Project1
Then I installed react-native-video : npm install --save react-native-video
I used then this : react-native link react-native-video
I only have for the moment App.js :
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Video from 'react-native-video';
export default function App() {
return (
<View style={styles.container}>
<Video source={{uri: './small.mp4'}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}} // Store reference
o.nBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo} />
</View>
);
}
Finally I use npm start
I have this error message :
undefined is not an object (evaluating 'RCTVideoInstance.Constants')
Stack trace:
node_modules/react-native-video/Video.js:265:11 in render
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:13042:21 in finishClassComponent
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:12970:4 in updateClassComponent
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:307:15 in invokeGuardedCallbackImpl
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:531:36 in invokeGuardedCallback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20488:8 in beginWork$$1
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19370:24 in performUnitOfWork
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19347:39 in workLoopSync
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18997:22 in renderRoot
[native code]:null in renderRoot
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18709:28 in runRootCallback
[native code]:null in runRootCallback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5642:32 in runWithPriority$argument_1
node_modules/scheduler/cjs/scheduler.development.js:643:23 in unstable_runWithPriority
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5638:22 in flushSyncCallbackQueueImpl
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5627:28 in flushSyncCallbackQueue
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18556:30 in scheduleUpdateOnFiber
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21822:15 in scheduleRootUpdate
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:23042:20 in ReactNativeRenderer.render
node_modules/react-native/Libraries/ReactNative/renderApplication.js:52:52 in renderApplication
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:116:10 in runnables.appKey.run
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:197:26 in runApplication
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:17 in __guard$argument_0
[native code]:null in callFunctionReturnFlushedQueue
...
I followed instructions from react-native-video : https://www.npmjs.com/package/react-native-video
Thanks a lot...
You have to eject your app from expo and use the bare workflow if you want to use "react-native-video".
Btw, you can use Expo Video instead of react-native-video : https://docs.expo.io/versions/latest/sdk/video/