react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android]Playing videos in webView

Open openGeeksLab opened this issue 10 years ago • 3 comments

Video not play in WebView Android. movie.content = "http://broken-links.com/tests/media/BigBuck.m4v"; const HTML = '<video id="video"style="background-color:green;" autobuffer autoplay height="90%" width="100%" preload="auto" loop webkit-playsinline="webkit-playsinline" controls="controls"><source src="'+movie.content+'" type="video/mp4"/></video>'; <WebView ref="webViewAndroidSample" javaScriptEnabled={true} domStorageEnabled={true} allowsInlineMediaPlayback={true} injectedJavaScript={jsCode} html={HTML} />;

openGeeksLab avatar Mar 21 '16 12:03 openGeeksLab

Try this from Stackoverflow.

I know from a previous project we did that you need to use the WebChromeClient to get HTML5 video to play. (And this also gives you hardware accelerated support too - providing you also set the flags on your activity).

Use: mainWebView.setWebChromeClient(new WebChromeClient());

Put that before you set the setWebViewClient. You can override the WebChromeClient to intercept any events you need to handle.

And in your AndroidManifest.xml within your activity definition, add: android:hardwareAccelerated="true"

The following quote is from this SDK Page (scroll down to HTML5 Video support)

In order to support inline HTML5 video in your application, you need to have hardware acceleration turned on, and set a WebChromeClient.

pontusab avatar Mar 21 '16 14:03 pontusab

You need to make sure that your device and android version supports webGL in order to play html5 video in your application.

shraddha1704 avatar Mar 22 '16 05:03 shraddha1704

Duplicated of: #6405

lucasfeliciano avatar Mar 23 '16 13:03 lucasfeliciano