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
  • 241,084
  • 71
  • 387
  • 401
manuelBetancurt
  • 15,428
  • 33
  • 118
  • 216

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
  • 22,885
  • 5
  • 42
  • 63
petrumo
  • 1,116
  • 9
  • 18