有没有办法在 React Native 中添加视频元素(for Android)?

Is there a way to add video elements in React Native (for Android)?

我正在搜索文档,但尚未成功找到示例代码。 我需要从我的流服务器播放视频。有什么办法吗?或者可能是 react-js 还不支持 android 上的视频。

React Native 不支持。

我没有用过这个,但是你可能会在这个插件中找到你需要的东西:https://github.com/ms88privat/react-native-video-gstreamer

是的。我花了一段时间才弄清楚,但解决方案很简单。

使用跨平台 iOS 和 Android 的 react-native-video 组件。

实施: 再简单不过了...

<Video source={{ uri: 'http://STREAM_URL/playlist.m3u8' }} />


在 iOS 和 Android 上播放实时 HLS .m3u8 流的提示:

在 iOS: 请确保在 info.plist 上的 App Transport Security Settings 中允许流的源域作为例外域。在测试时,我将 "Allow Arbitrary Loads" 设置为 YES。在我这样做之前,流根本没有通过。

在 Android: 使用 react-native-video 1.0 中引入的新 exoplayer 变体。启用方法如下:#426 (comment)