0

I am working on app which contain inline image and embeded video in HTML content. video displayed but clicking on play button video wont play. I have used following code of loading html content on webview.

WebSettings mainViewsettings = witContentWebView.getSettings();
mainViewsettings.setJavaScriptEnabled(true);
mainViewsettings.setAllowFileAccess(true);
mainViewsettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);

mainViewsettings.setLoadWithOverviewMode(true);
mainViewsettings.setBuiltInZoomControls(true);
mainViewsettings.setDomStorageEnabled(true);

witContentWebView.setWebChromeClient(new WebChromeClient() 
{

});

witContentWebView.loadDataWithBaseURL("", witsContentStr,"text/html", "UTF-8", "");

I have also set android:hardwareAccelerated="true" in manifest file, but I did not get any success. Could you guys help me solveout in this.

2 Answers2

0

Maybe problem in is codec? Just open a browser? You use Chromium Web View or old Web View? (Android version)

user2413972
  • 1,355
  • 2
  • 9
  • 25
0

Answer shamelessly copied from https://stackoverflow.com/a/3520920/1602333.

I am not sure if this is what you need. Anyway I hope the following be useful. You can use the iframe method that youtube provides to play its videos. If the browser supports html5 will show the video with it, otherwise with flash.

You can use the following code as an example <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/bIPcobKMB94" frameborder="0">

in the above example the video id is bIPcobKMB94. You can change this id and show your video.

You can access a live example of it here

More infromation for youtube iframe

YouTube HTML5 Video Player

Community
  • 1
  • 1
MohK
  • 1,873
  • 1
  • 18
  • 29