本机。我正在尝试使用react-native-video显示视频,但是出现以下错误
错误:元素类型无效:预期为字符串(对于内置 组件)或类/函数(用于复合组件),但得到: 数字。
检查
VideoAndroid
的呈现方法。
我没有得到这个错误是什么?谁能帮我。
提前谢谢
这是代码段
// all imports
import React, { useState, useEffect } from 'react'
import { Image, StyleSheet, Text, Dimensions, TouchableWithoutFeedback, TouchableOpacity , View, StatusBar } from 'react-native'
import Video, {
OnSeekData,
OnLoadData,
OnProgressData,
} from 'react-native-video';
import VideoPlayer from 'react-native-video-controls';
import Orientation from 'react-native-orientation-locker';
import { FullscreenClose, FullscreenOpen } from '../../assets/icons';
interface State {
fullscreen: boolean;
play: boolean;
currentTime: number;
duration: number;
showControls: boolean;
}
const VideoAndroid = () => {
const videoRef = React.createRef<Video>();
const [state, setState] = useState<State>({
fullscreen: false,
play: false,
currentTime: 0,
duration: 0,
showControls: true,
});
return(
<>
<View style={styles.container}>
<TouchableWithoutFeedback onPress={showControls}>
<View>
<Video
ref={videoRef}
source={{
uri:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
}}
style={state.fullscreen ? styles.fullscreenVideo : styles.video}
controls={false}
resizeMode="contain"
onLoad={onLoadEnd}
onProgress={onProgress}
onEnd={onEnd}
paused={!state.play}
/>
{state.showControls && (
<View style={styles.controlOverlay}>
<TouchableOpacity
onPress={handleFullscreen}
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
style={styles.fullscreenButton}>
{state.fullscreen ? <FullscreenClose /> : <FullscreenOpen />}
</TouchableOpacity>
</View>
)}
</View>
</TouchableWithoutFeedback>
</View>
</>
)
}