react-native-webview: Videos in iFrame do not work in webview
I have a problem with playing video wrapped to iFrame from YouTube and Instagram. A problem is in Android. Ios works fine.
So, when I put inframe into webview it looks ok. Until i click on play button. Video start load all native buttons are available and sound works fine but the movie is black. But sound and stop/play buttons works
We use react-native-cli: 2.0.1 react-native: 0.57.5 and “react-native-webview”: “^2.12.1”
I prepared a simple demo where that videos don’t work:
render() {
return (
<WebView
originWhitelist={['*']}
useWebKit={false}
source={{
html: `
XX
<div>
<iframe width="320" height="240" src="https://www.youtube.com/embed/li8yILhFFZM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div> `
}}
/>
);
}
}
and screenshot of the problem:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 51 (4 by maintainers)
set as below androidHardwareAccelerationDisabled={false}
it works for me
I have tried to fix that issue by adding both attributes. However,
mixedContentMode='always'
does not work for me and An app crashed after theandroidHardwareAccelerationDisabled={false}
when it navigate between web-views. does anyone have the same problem with the above configuration?Add “androidLayerType={‘hardware’}” it work for me.
@NetPumi2 @Titozzz @wendelfreitas @jamonholmgren HI everyone, this library https://github.com/teamairship/react-native-android-fullscreen-webview-video fixing the problem with fullscreen video on the Android (in my case). Can you check it and add functionality to this repo if everything will be ok?
set as below mixedContentMode=‘always’
it works for me
I’m having the exact same problem! any luck finding a solution?
mixedContentMode do not work for me
and about
setWebChromeClient
this is already setup in this repohttps://github.com/react-native-community/react-native-webview/blob/48230e4dcff2ad234d2617026924d07e106c2022/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java#L400
@jkustan Thanks for the detailed report. So far I’ve been unable to reproduce this on anything but an emulator and just chalked it up to emulator issues since those things are pretty flaky to begin with. Could you include some more detail about the physical devices you are seeing this on? Anything that looks related in the logs on that device when the video starts playing?
i use android simulator have the black problem,after i use true android phone everything is well!(sorry for my poor english)
@wendelfreitas Yes fullscreen do not work too. I google it a lot but I didn’t find anything similar
Thanks for reporting, anyone want to dive in and see if they can figure this out? (Might involve a bunch of Googling first to see if it’s a known problem with Android webview…)