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

查看:34
本文介绍了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天全站免登陆