是否可以使用切换按钮显示视频。我正在将this组件用于视频,并尝试使用切换按钮使视频可见。但是我对如何做到这一点有些困惑。顺便说一句,我不仅在尝试使其显示,而且还在打开视频时启动视频,在视频结束时关闭视频。
export default class App extends Component {
_onPress(){
const newState = !this.state.toggle;
this.setState({toggle:newState});
}
render() {
const url = 'https://player.vimeo.com/external/207277102.hd.mp4?s=6939b93ae3554679b57f5e7fa831eef712a74b3c&profile_id=119&oauth2_token_id=57447761'
const logo = 'https://your-url.com/logo.png'
const placeholder = 'https://your-url.com/placeholder.png'
const title = 'My video title'
return (
<View style={styles.container}>
<ScrollView>
<Text>Some content here...</Text>
</ScrollView>
<Video url={url}
title={title}
logo={logo}
placeholder={placeholder}
/>
<TouchableOpacity
onPress={()=>this._onPress()}
style={{backgroundColor:"dodgerblue"}}
>
<Text style={styles.buttonStyles}>Tab the Button</Text>
</TouchableOpacity>
<ScrollView>
<Text>Some content here...</Text>
</ScrollView>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
buttonStyles: {
color:'white',
textAlign: 'center',
fontSize: 16
}
});
AppRegistry.registerComponent('VideoExample', () => VideoExample);
我真的很感谢任何例子...