在哪里放置Android webview html5混合应用程序的本地视频文件 [英] where to place local video files for android webview html5 hybrid app

查看:191
本文介绍了在哪里放置Android webview html5混合应用程序的本地视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从资产文件夹加载html页面到android webview,html页面有视频。其他图像加载清楚但视频未加载我的意思是不在应用程序中播放。放置本地视频文件的位置?我通过将视频文件放在资产文件夹和原始文件夹中进行测试,但不播放视频。

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

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

请提前帮助我。

推荐答案

我将视频文件放在RAW文件夹中,并通过以下代码访问default.html文件中的视频文件:

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();

它像我想要的那样播放视频。还在AndroidManifest文件中添加以下行。

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

android:hardwareAccelerated="true"

使用showCustomView& WebChromeClient的hideCustomView方法。我所做的是在我的main.xml中保留一个Framelayout(customContainer),并在此处添加在showCustomView中收到的视图,并在onHide中删除它。同时隐藏/显示webview。

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.

这篇关于在哪里放置Android webview html5混合应用程序的本地视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆