react-native - 在 react-native-video 中播放 youtube 视频

标签 react-native react-native-video

我如何在 react-native-video 上播放 youtube 视频,
我不想在 react-native-youtube 或 webview 中播放视频,

最佳答案

我检查和使用的另一个选项是 WebView。要使用它,请确保将组件放在带有 flex 的 View 中。前任:

<View style={{flex: 1}}>
    <WebView
        style={ {  marginTop: (Platform.OS == 'ios') ? 20 : 0,} }
        javaScriptEnabled={true}
        domStorageEnabled={true}
        source={{uri: 'https://www.youtube.com/embed/'+this.state.pictureData.idVideo }}
    />
</View>

就我而言,我所做的是获取 YouTube 视频的识别部分,例如:https://www.youtube.com/watch?v= KQ6zr6kCPj8

this.state.pictureData.idVideo 将只包含:KQ6zr6kCPj8

要使用它,请安装:
  • $ npm install --save react-native-webview
  • 链接 react-native-webview

  • 如果您想了解更多信息:
    https://github.com/react-native-community/react-native-webview

    关于react-native - 在 react-native-video 中播放 youtube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57413156/

    相关文章:

    ios - react-native 的 Realm 给出 IOS 版本警告

    react-native - 如何更改 native 应用程序中文本输入的边框颜色

    javascript - 如何使用 React-Native 连接 MS SQL 数据库?

    javascript - react native Android 生成签名 APK 给出资源错误

    react-native - 在 iOS 11 上启动屏幕后应用程序闪烁白色?

    webview - (React Native) 将本地 HTML 文件加载到 WebView 中

    react-native - 视频的背景音频 react-native-video

    react-native - 如何使用react-native-video播放谷歌驱动器中的视频?

    react-native - 错误 react native 视频 : undefined is not an object (evaluating 'RCTVideoInstance.Constants' )

    react-native - 我在包含 'react-native-video' 中的 {Video} 后收到此错误。否则我的代码工作正常