react-native - react 原生YouTube-组件不可见

标签 react-native youtube

安装到我的页面时,我看不到播放器:

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-youtubereact-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/

相关文章:

javascript - 在 React Native 天才聊天中,我如何将点击作为普通消息处理?

video - IE8中的YouTube视频嵌入错误

youtube - WKWEbView 在 iOS 中隐藏 native 播放器的控件

javascript - react 导航, Prop 验证中缺少 tintColor

react-native - 如何在React Native Redux的Reducer中向数组添加元素?

youtube - jekyll/octopress嵌入式youtube视频缓存问题

video - 如何在榆树应用程序中嵌入视频

python - 使用 python gdata 通过 URL 将视频上传到 YouTube

javascript - 如何在 React-Native 中使用时间来发出通知?

react-native - React Native Toolbar Android 溢出图标是黑色的——我可以更改它的颜色还是需要完全替换它?