如何使用 React Native 显示视频

时间:2021-05-18 13:30:46

标签: react-native video react-native-video

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

我运行了这些命令,但它不起作用: npm install react-native-video react-native 链接 react-native-video

这是我的代码:

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>
        )
    }
}

1 个答案:

答案 0 :(得分:0)

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

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