如何使用 React native 显示视频

How to Display Video with React native

我试图在 React Native 应用程序上显示视频,但是当我 运行 应用程序时出现错误 TypeError: undefined is not an object (evaluating 'RCTVideoInstance.Constants')

我运行这些命令但它不起作用: npm 安装 react-native-video 反应本机 link 反应本机视频

这是我的代码:

import React from "react";
import {View} from 'react-native';
import CustomBackground from '../Components/CustomBackground';
import Video from 'react-native-video';
import videooo from '../Images/videooo.mp4'


export default class WelcomeScreen extends React.Component{

    render(){
        return(
           <CustomBackground>
                    <View style={styles.btnWelcome}>
                        <Video source={videooo} style={styles.images} onBuffer={this.onBuffer} onEnd={this.onEnd} onError={this.videoError}/>
                    </View>
                           
            </CustomBackground>
        )
    }
}

尝试使用 expo-av 而不是 react-native-video

更多信息:https://github.com/react-native-video/react-native-video/issues/1738#issuecomment-575243702