React native 在React Native中显示视频
我正在尝试用react native显示视频。但是有一些问题到目前为止,我所做的是:安装react本地视频。并把它联系起来 这是代码:React native 在React Native中显示视频,react-native,react-native-video,React Native,React Native Video,我正在尝试用react native显示视频。但是有一些问题到目前为止,我所做的是:安装react本地视频。并把它联系起来 这是代码: import React, {Component} from 'react'; import { AppRegistry, Platform, StyleSheet, Text, View, ScrollView, TouchableOpacity, Button, Alert} from 'react-native';
import React, {Component} from 'react';
import {
AppRegistry,
Platform,
StyleSheet,
Text,
View,
ScrollView,
TouchableOpacity,
Button,
Alert} from 'react-native';
import Video from 'react-native-video';
export default class App extends Component<Props> {
Open() {
}
render() {
return (
<View style={styles.container}>
<Text>
Open the video
</Text>
<Button
onPress={this.Open}
title="Press Me"
/>
<Video
source={{ uri:"https://www.youtube.com/watch?v=HIB8RBhPkBA"}}
resizeMode={"cover"}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor : 'white',
alignItems: 'center',
justifyContent: 'center'
},
});
import React,{Component}来自'React';
进口{
评估学,
平台,
样式表,
文本,
看法
滚动视图,
可触摸不透明度,
按钮
来自“react native”的警报};
从“react native Video”导入视频;
导出默认类应用程序扩展组件{
开(){
}
render(){
返回(
打开视频
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“白色”,
对齐项目:“居中”,
为内容辩护:“中心”
},
});
模拟器中没有错误。但也没有视频。我在安装方面有没有做错什么 不幸的是,react原生视频将无法工作,因为源uri是指向youtube页面的链接。除非您可以将视频作为一项资产获取并将其扩展名附加到其url(…video.mp4),否则它应该可以工作。看
为了快速修复,您可以使用
webview
组件嵌入链接。不幸的是,react原生视频无法工作,因为源uri是指向youtube页面的链接。除非您可以将视频作为一项资产获取并将其扩展名附加到其url(…video.mp4),否则它应该可以工作。看
对于快速修复,您可以使用
webview
组件嵌入链接。对于显示youtube视频,您可以使用此软件包
API
从“react native YouTube”导入YouTube
<YouTube
videoId="KVZ-P-ZI6W4" // The YouTube video ID
play={true} // control playback of video with true/false
fullscreen={true} // control whether the video should play in fullscreen or inline
loop={true} // control whether the video should loop when ended
onReady={e => this.setState({ isReady: true })}
onChangeState={e => this.setState({ status: e.state })}
onChangeQuality={e => this.setState({ quality: e.quality })}
onError={e => this.setState({ error: e.error })}
style={{ alignSelf: 'stretch', height: 300 }}
/>
this.setState({isReady:true})
onChangeState={e=>this.setState({status:e.state})}
onChangeQuality={e=>this.setState({quality:e.quality})}
onError={e=>this.setState({error:e.error})}
样式={{alignSelf:'stretch',高度:300}
/>
要从url获取youtube id,您可以使用
var video_id=window.location.search.split('v=')[1];
var-ampersandPosition=video_id.indexOf('&');
如果(符号与位置!=-1){
video_id=video_id.子字符串(0,安培和位置);
}
要显示youtube视频,您可以使用此软件包
API
从“react native YouTube”导入YouTube
<YouTube
videoId="KVZ-P-ZI6W4" // The YouTube video ID
play={true} // control playback of video with true/false
fullscreen={true} // control whether the video should play in fullscreen or inline
loop={true} // control whether the video should loop when ended
onReady={e => this.setState({ isReady: true })}
onChangeState={e => this.setState({ status: e.state })}
onChangeQuality={e => this.setState({ quality: e.quality })}
onError={e => this.setState({ error: e.error })}
style={{ alignSelf: 'stretch', height: 300 }}
/>
this.setState({isReady:true})
onChangeState={e=>this.setState({status:e.state})}
onChangeQuality={e=>this.setState({quality:e.quality})}
onError={e=>this.setState({error:e.error})}
样式={{alignSelf:'stretch',高度:300}
/>
要从url获取youtube id,您可以使用
var video_id=window.location.search.split('v=')[1];
var-ampersandPosition=video_id.indexOf('&');
如果(符号与位置!=-1){
video_id=video_id.子字符串(0,安培和位置);
}
哇,哇,亚马逊s3视频怎么样?亚马逊s3视频怎么样?