android - 无法在 react-native 的默认 WebView 上播放 hls

标签 android webview react-native live-streaming http-live-streaming

我正尝试在我的 webview 上播放一个 https 直播流媒体视频 react-native import { WebView } from 'react-native';

但是视频没有播放,我不知道为什么,当我使用不同的浏览器(例如 .. google chrome)时,它正在我的移动设备上的那个浏览器上播放,但是当我使用 webview 时react-native,没用

我的网页 View 代码:

 <WebView
      source={{uri: `https://link to video that has a live streaming`}}
      // source={{uri: 'https://www.youtube.com/'}}
      style={styles.webView}
      mediaPlaybackRequiresUserAction={false}
      javaScriptEnabled={true}
      domStorageEnabled={true}
      useWebKit={true}
  />

我已经尝试过 youtube 上的 url 并且那里的视频可以在我的 webview 上播放,我该怎么办? 我的设备是安卓牛轧糖。

最佳答案

也许有点晚了,但是,你可以试试这样的东西。

const uri = "https://link to video that has a live streaming"
const html = `<video controls width="500" height="50">
            <source src="${uri}" type="application/x-mpegURL">
            </video>`;
return (
    <WebView
      allowsFullscreenVideo
      originWhitelist={["*"]}
      source={{ html }}
    />

关于android - 无法在 react-native 的默认 WebView 上播放 hls,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53515486/

相关文章:

Android:如何向主 Activity 添加另一个 fragment

flutter - Flutter WebView 中的 Cookie 字符串

javascript - 在 React Native 应用程序中调试 WebView

javascript - React Native Redux 如何更新 UI,在调用没有使用标志的 API 后导航到新屏幕

android - 如何更改微调器中的下拉高度

android - 从 SdCard android 解码文件以避免由于大位图或 setImageURI 而导致内存不足错误

android - android studio的HierarchyViewer工具如何知道android屏幕 View 的属性

javascript - Android webview - JavaScript 回调不起作用?

javascript - JS文件中React Component类之外的代码什么时候运行?

react-native - React Native 中的最小宽度/高度