Videos in a webview doesn't play
See original GitHub issueBug description: It is not possible to play any video in a webview. I have already tried videos from youtube (embedded, iframe, in an html file), vimeo … no video works, no image, no sound, just an inifinite loading. Opening the same link in the device’s default browser, the video starts playing. Opening the same link through the webview the page is loaded but the video doesn’t play.
Notes:
- I added
android:hardwareAccelerated="true"
in androidManifest and<uses-permission android:name="android.permission.INTERNET"/>
- I created a simple native example on android using webview and any video works without any problem.
- I implemented a native ui component that when mounted starts a webview in an activity and it works.
- If i put the code bellow in the Main Activity of my app it also works.
@Override
@CallSuper
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
webView = new WebView(this);
setContentView(webView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccess(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
});
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("https://www.youtube.com/embed/TQsl9nxs_1o?autoplay=1");
}
}
Environment:
- Device: Fire TV Stick (Gen 2)
- OS version: Fire OS 5
- Android version : Android Level 22 (Android 5.1)
- react-native version: 0.63.2
- react-native-webview version: 10.8.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:34 (1 by maintainers)
Top Results From Across the Web
Videos in a webview doesn't play · Issue #1632 · react-native ...
no video works, no image, no sound, just an inifinite loading. Opening the same link in the device's default browser, the video starts...
Read more >Android webview cannot play video file error - Stack Overflow
Just tried your video url in my webview and it worked. Here are my settings: webView.getSettings().setJavaScriptEnabled(true); webView.
Read more >Video from an embedded tweet doesn't play with WKWebView ...
I'm faced an issue of playing video from embedded to HTML tweets. The behavior which I'm looking for is simple enough: to have...
Read more >Embedded Video not playing in WebView with iOS 13
You can try and either set the customUserAgent on the webview to something closer to the iPhone's default User-Agent so the HTML5 video...
Read more >How to play audio/video in WebView from MemoryStream on ...
On Android, I'm using a custom WebViewClient to provide a MemoryStream in a ShouldInterceptRequest override for loaded resources. This works ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
set as below mixedContentMode=‘always’
it works for me
<WebView mediaPlaybackRequiresUserAction={true} androidLayerType= ‘hardware’ mixedContentMode=‘always’ style={{ height: 240, width: 320, alignSelf: “center”, alignContent: “center”, }} javaScriptEnabled={true} source={{ uri:
https://www.youtube.com/embed/sFFwvr6l2mM? =0&autoplay=0&showinfo=0&controls=0&fullscreen=0
}} /> I have this code but only audio is playing video not visible