I am showing videos in a WebView from a videoUrl
, which is a YouTube embed link.
<WebView
javaScriptEnabled={true}
allowsFullscreenVideo={true}
allowsInlineMediaPlayback={true}
ref={(ref) => { webview = ref }}
onNavigationStateChange={(event) => {
if(event.url !== videoUrl) {
webview.stopLoading()
Linking.openURL(event.url)
}
}}
source={{ uri: videoUrl }}
/>
When setting a height
or minHeight
, it shows at that height and the full width, and the video works correctly. The problem is that I have found no way of setting the height automatically, so depending on the device width the video is usually cropped. I have already tried these libraries, to no avail:
https://github.com/iou90/react-native-autoheight-webview
https://github.com/scazzy/react-native-webview-autoheight