安装到我的页面时,我看不到播放器:
return (
<YouTube
apiKey="xxx"
videoId={youtubeVideo} // The YouTube video ID
play={false} // control playback of video with true/false
fullscreen={false} // control whether the video should play in fullscreen or inline
loop={false} // control whether the video should loop when ended
onReady={e => console.log('ready')}
onChangeState={e => console.log('onchange')}
onChangeQuality={e => console.log('change quality')}
onError={e => console.log(e.error)}
style={{ alignSelf: "stretch", height: 300 }}
/>
);
我收到
onReady
回调的控制台日志,但没有视频。如何显示我的视频?有更好的选择吗?研究了这两个软件包
react-native-youtube
和react-native-vimeo
。两者都没有维护好一段时间,并且有很多问题。嵌入来自YouTube的视频的最佳方法是什么,该视频既适合Play商店也适用于App Store。 Play商店中有很多基于视频的应用程序,其他人怎么做?
最佳答案
您的YouTube组件是否通过flex包裹在父 View 中?我在我的应用程序中使用了相同的程序包,它似乎运行良好,这几乎就是我设置程序的方式。
// Parent view (page container)
<View style={{ flex : 1 }}>
...
<Youtube
apiKey={API_KEY}
videoId={videoID}
style={{ marginTop : 15, height : 250, alignSelf : 'stretch' }} />
...
</View>
关于react-native - react 原生YouTube-组件不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56562256/