我正尝试在我的 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/