gpt4 book ai didi

react-native - 错误 react native 视频 : undefined is not an object (evaluating 'RCTVideoInstance.Constants' )

转载 作者:行者123 更新时间:2023-12-05 05:03:30 32 4
gpt4 key购买 nike

我想在我的应用中使用 react-native-video。但是,我所做的不起作用:

  1. 我使用 expo init Project1

    创建了一个新项目
  2. 然后我安装了 react-native-video :npm install --save react-native-video

  3. 然后我使用了这个:react-native link react-native-video

我暂时只有 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>
);
}

最后我使用npm start

我有这个错误信息:

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
...

我遵循了 react-native-video 的说明:https://www.npmjs.com/package/react-native-video

非常感谢...

最佳答案

如果您想使用“react-native-video”,您必须从 expo 中退出您的应用并使用裸工作流。

顺便说一句,您可以使用 Expo Video 而不是 react-native-video :https://docs.expo.io/versions/latest/sdk/video/

关于react-native - 错误 react native 视频 : undefined is not an object (evaluating 'RCTVideoInstance.Constants' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61613898/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com