20

I have an embedded html file in my file system, it works fine if I drag n drop the file to

assets/index.html

and I have tested the HTML5 video playback from here. Works fine.

Now, if I want to show an embedded page with HTML5 video [working on browser] as an embedded file, just by changing the sample code for the HTML5 android webView player and drag n drop the index.html in assets for this project, it doesn't work, the app crashes with this error:

sorry, the app * has stopped unexpectedly...

so I just change

mWebView.loadUrl("http://freebsd.csie.nctu.edu.tw/~freedom/html5/");

to

mWebView.loadUrl("file:///android_asset/index.html");

It doesn't work.

What am I missing, is there a basic example of HTML5 video embedded?

Fenton
  • 224,347
  • 65
  • 373
  • 385
manuelBetancurt
  • 14,346
  • 29
  • 109
  • 206

2 Answers2

0

Try putting index.html in assets/www/index.html and change mWebView.loadUrl("file:///android_asset/index.html"); to mWebView.loadUrl("file:///android_asset/www/index.html");

joequincy
  • 1,395
  • 10
  • 21
Rishi
  • 330
  • 2
  • 13
0

Try using loadDataWithBaseURL:

String baseUrl = shouldUseCachedFiles ? "file:///android_asset/"
                        :mUrl;
mWebView.loadDataWithBaseURL(baseUrl, htmlContent, "text/html",
                        "utf-8", baseUrl);

where the htmlContent is retrieved with an AsynchTask and loaded into the webView.

grc
  • 21,645
  • 4
  • 39
  • 63
petrumo
  • 1,098
  • 9
  • 18