Like the title says, I need to load a video (.mp4) from the assets folder into a WebView.
I’ve tried a couple of things:
//First
String webpage = "<!doctype html><head><meta charset='utf-8'></head><body><video id='video' controls='controls' autoplay='autoplay' height=" + m.getHeight() + " width=" + m.getWidth() + "><source src='file:///android_asset/1003/landscape_1003_1_m864.mp4' /></video></body></html>";
wv.loadData(webpage, "text/html", "utf-8");
//Second
Load the same webpage but using the loadUrl() method
wv.loadUrl(webpage);
//Third
Loading the exact same webpage but with another method
wv.loadDataWithBaseURL("file:///android_asset/", webpage,"text/html", "utf-8", null);
I’ve tried to change the first parameter to null,also the webpage, …
Everything has to be added dynamically (the webview itself, the url to the video, the width, height, …) so making a XML file is not an option.
A lot of solutions I’ve found on the internet was to move the video to the Raw folder or SD card, but that is not an option (business decision).
It would be nice if somebody could help me.
P.S. If you could help me with the exact same thing but showing the video in a videoview with all the controls like a html5 video element (play, pause, seekbar, fullscreen) feel free!
I had the same issue. Unfortunately I didn’t find a solution. Instand of this I just do something like this:
Open video
..and my video player: