where to place local video files for android webview html5 hybrid app

旧街凉风 提交于 2020-02-10 04:24:24

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/17020270/where-to-place-local-video-files-for-android-webview-html5-hybrid-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!