【发布时间】:2018-02-20 17:46:03
【问题描述】:
我是 React Native 的新手。我面临 Youtube 视频仅播放音频的问题。下面是我现在使用的代码:
import React, { Component } from 'react'
import {
View,
ListView,
WebView,
StyleSheet,
ScrollView
}
from 'react-native'
url=[
{
"videourl":"https://www.youtube.com/embed/ZnvJvZAJZPk",
},
{
"videourl":"https://www.youtube.com/embed/HOI8nlFa86U",
},
{
"videourl":"https://www.youtube.com/embed/0bDI_rAMV68",
},
]
class WebViewExample extends Component{
constructor (props) {
super (props);
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
this.state = {
dataSource: ds.cloneWithRows(url),
};
}
render(){
return (
<ListView
dataSource={ this.state.dataSource }
renderRow={this.renderRows.bind(this)}
/>
);
}
renderRows(rowData){
console.log("url: "+rowData.videourl);
return(
<View style={styles.container}>
<View style={{borderWidth:3, borderColor : '#FF0000', flex:1}}>
<WebView source={{uri: rowData.videourl}} style={{}} />
</View>
</View>
);
}
}
export default WebViewExample;
const styles = StyleSheet.create({
container: {
height: 350,
}
})
React 原生版本:0.47
【问题讨论】:
-
我可以在移动设备上观看视频。可能是世博会不支持该视频。
-
您好,感谢您的回复。我正在使用android模拟器进行测试。但仍然只播放音频。
标签: android listview react-native webview youtube