3

This is my first question so please be gentle...

Ok, here is the problem. I have to show a video inside a WebView in Android. I have tested it on multiple devices and Android versions and it does not work consistently.

  • Nexus 10 (4.2.2) - works perfectly;
  • Nexus 4 (4.2.2) - works perfectly;
  • Galaxy Tab 10.1 (4.0.4) - only sound;
  • Nexus S(4.1.2) - works perfectly;
  • LG Optimus One (2.3.3) - does absolutely nothing;

I simply can't find the problem, nor a similar problem online...

This is a sample video I have to display:

<html>
<div style="display:none">

</div>

<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>

<object id="myExperience2084424914001" class="BrightcoveExperience">
  <param name="bgcolor" value="#FFFFFF" />
  <param name="width" value="448" />
  <param name="height" value="282" />
  <param name="playerID" value="1628834100001" />
  <param name="playerKey" value="AQ~~,AAABCTwHZPk~,hTXeDm36Z7Rd3QTKipeWv6uC6OAmrw2j" />
  <param name="isVid" value="true" />
  <param name="isUI" value="true" />
  <param name="dynamicStreaming" value="true" />

  <param name="@videoPlayer" value="2084424914001" />
</object>

<script type="text/javascript">brightcove.createExperiences();</script>
</html>

And here is a sample of the WebView in Android...

try {
                        webviewC = (WebView) findViewById(R.id.webviewRSS);
                        webviewC.getSettings().setJavaScriptEnabled(true);
                        webviewC.getSettings().setDomStorageEnabled(true);
                        webviewC.getSettings().setSupportZoom(true);
                        webviewC.getSettings().setBuiltInZoomControls(true);
                        webviewC.getSettings().setUseWideViewPort(true);

                        // show loading progress in the title bar
                        webviewC.setWebChromeClient(new WebChromeClient() {
                            @Override
                            public void onProgressChanged(WebView view, int progress) {
                                activity.setProgress(progress);
                                // The progress meter will automatically disappear
                                // when
                                // we reach 100%
                                if (progress == 100) {
                                    setProgressBarVisibility(View.GONE);
                                }
                            }
                        });

                        // show message if error
                        webviewC.setWebViewClient(new WebViewClient() {
                            @Override
                            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                                Toast.makeText(activity, "Desole! " + description, Toast.LENGTH_SHORT).show();
                            }
                        });
                        webviewC.loadDataWithBaseURL("http://www.somebaseurl.org", aStringContainingHTML, "text/html", "UTF-8", "");
                    } catch (Exception e) {
                        Toast.makeText(activity, "Oh, no! " + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }

UPDATE!

The video section I get must be displayed in a WebView (client request) and I get the html section I just posted from an XML flux, so there is no option there either...

Adrian Sicaru
  • 1,382
  • 1
  • 11
  • 20
  • why dont u use flash to play ur video becoz android has variant version of os and device running in the market with different webkit engine , it will be better to run the video in flash ,onward 2.3 flash player work good .. ie – Vipin Sahu May 13 '13 at 12:04
  • Well, because this is how I get the video from the client and because flash is no longer supported on Android, neither by Google, nor by Adobe – Adrian Sicaru May 13 '13 at 12:16
  • http://helpx.adobe.com/flash-player/release-note/flash-player-10-1-android.html,,, you can also host video to youtube and fire an intent to launch it , following that intent matching apps will come as a list and u can easliy be able to play video – Vipin Sahu May 13 '13 at 12:36
  • some possible solution are here u can have a look at this http://stackoverflow.com/questions/7586475/google-reader-esque-optimizing-of-webviews-on-android – Vipin Sahu May 13 '13 at 12:40

1 Answers1

3

It is possible that browser not support HTML5 tags for display and playing video.

Brajendra Pandey
  • 2,280
  • 1
  • 16
  • 22
  • Ok, but how come it works on some versions of android and not on others? and what is to be done? – Adrian Sicaru May 13 '13 at 12:05
  • some times your android webView and default browser not support to show video try to download Mozilla or any other browser and try to run video. and try to give link to open video in particular browser using javascript.and also enable javascript in webView using setJavaScriptEnable(true) method – Brajendra Pandey May 13 '13 at 12:19
  • 1
    Java script is enabled, as you can see from my sample code. And yes, in browsers, there is no problem, just in webView. And the nature of my app requires that i display the data in WebView, so changing that is not an option. – Adrian Sicaru May 13 '13 at 12:26
  • research and development – Syed Raza Mehdi Dec 30 '14 at 05:31