2

I am loading html page from asset folder to android webview, the html pages has video. Other images are loaded clearly but video is not loaded i mean not plays in app. Where to place the local video file? I tested by placing video files in asset folder and raw folder, but not plays video.

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


video.src="file:///android_res/raw/test.mp4"; // load video file from raw folder

and

video.src="file:///android_asset/test.mp4";  // load video file from assets folder

Please help me, thanks in advance.

Dhananjay C
  • 597
  • 9
  • 34

1 Answers1

4

I placed video files in RAW folder and access video file in default.html file by following code:

video.src ="android.resource://ProjectPackageAame/raw/test";
video.type = "video/mp4";      
video.load(); 
video.play();

It playes video like i want. Also added following line in AndroidManifest file.

android:hardwareAccelerated="true"

For playing video in full screen mode used showCustomView & hideCustomView method of WebChromeClient. What i have done is kept one Framelayout(customContainer) in my main.xml, and adding view received in showCustomView here, and removing it in onHide. Also hiding/showing webview accordingly.

Dhananjay C
  • 597
  • 9
  • 34
  • The ".mp4" suffix actually needs to be omitted (like in the example), I couldn't use subfolders inside the raw folder and I couldn't use filenames with special characters. – Twilite Jun 23 '14 at 09:25