Android 解析标准的点击第三方文件管理器中的视频的intent
解析标准的第三方视频intent
private List<String> mCurPlayList = new ArrayList<String>();
private int mCurPosition = 0; // 当前的位置信息
if (intent != null && TextUtils.equals(intent.getAction(), Intent.ACTION_VIEW)
&& !TextUtils.isEmpty(intent.getType()) && intent.getType().contains("video")) {
// 用来解析标准的第三方视频intent
String data = intent.getDataString(); // 这个地方获取的是乱码需要解析 file:///mnt/udisk2/%E7%BE%A4%E6%98%9F%20-%20%E5%8C%97%E4%BA%AC%E7%A5%9D%E7%A6%8F%E4%BD%A0.mp4
String folder = data;
if (!TextUtils.isEmpty(data)) {
if (data.startsWith("file://")) {
data = Uri.decode(data).substring(7);
Logcat.d("initData replaceFirst data " + data);
}
if (data.lastIndexOf("/") > 0) {
folder = data.substring(0, data.lastIndexOf("/"));
Logcat.d("initData substring folder " + folder);
}
File file = new File(folder);
VideoUtils.GetVideoFile(mCurPlayList, file);
if (mCurPlayList != null && mCurPlayList.size() > 0) {
mCurPosition = mCurPlayList.indexOf(data);
}
}
Logcat.d("initData " + data + "; mCurPosition " + mCurPosition);
}
// 遍历指定目录的视频文件
public static void GetVideoFile(final List<String> mList, File file) {
if (mList == null) {
Logcat.w("mList is null ");
return;
}
if (file == null) {
Logcat.w("file is null ");
return;
}
mList.clear();
file.listFiles(new FileFilter() { @Override
public boolean accept(File file) {
if (FileUtils.isVideo(file)) {
mList.add(file.getAbsolutePath());
Logcat.d("initData AbsolutePath " + file.getAbsolutePath());
return true;
}
return false;
}
});
}
/** whether the file is video */
public static boolean isVideo(File file) {
String surfix = getFileSurfix(file);
return (surfix.equals("avi") || surfix.equals("mp4")
|| surfix.equals("3gp") || surfix.equals("rmvb")
|| surfix.equals("mov") || surfix.equals("wmv")
|| surfix.equals("mpeg") || surfix.equals("mpg")
|| surfix.equals("rm") || surfix.equals("vob")
|| surfix.equals("mkv") || surfix.equals("flv")
|| surfix.equals("asp") || surfix.equals("ASF")
|| surfix.equals("m2ts") || surfix.equals("ts")
|| surfix.equals("divx"));
}
/** Get file suffix from file path */
public static String getFileSurfix(File file) {
String surfix = ""; if (file != null) {
String filePath = file.getAbsolutePath();
surfix = getFileSurfix(filePath);
}
return surfix.toLowerCase();
}
/** Get file suffix from file path */
public static String getFileSurfix(String filePath) {
String surfix = ""; if (filePath != null) {
int surfixPos = filePath.lastIndexOf(".");
int surfixPosDivider = filePath.lastIndexOf("/");
// invalid : abcdefg.hijk/lmn
if (surfixPos > 0 && surfixPos > surfixPosDivider)
surfix = filePath.substring(surfixPos + 1, filePath.length());
} return surfix.toLowerCase();
}
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:mimeType="video/*"
android:scheme="http" />
<data
android:mimeType="video/*"
android:scheme="file" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
打印的日志:
11-02 09:34:03.739 2469-2469/? D/RRIVI: VideoPlayerActivity.java(318):initData: initData replaceFirst data /mnt/udisk2/Lady.GaGa.-.Poker.Face.avi
11-02 09:34:03.740 2469-2469/? D/RRIVI: VideoPlayerActivity.java(322):initData: initData substring folder /mnt/udisk2
11-02 09:34:03.744 2469-2469/? D/RRIVI: VideoUtils.java(86):accept: initData AbsolutePath /mnt/udisk2/Wildlife.wmv
11-02 09:34:03.744 2469-2469/? D/RRIVI: VideoUtils.java(86):accept: initData AbsolutePath /mnt/udisk2/江南丝带舞.mp4
11-02 09:34:03.745 2469-2469/? D/RRIVI: VideoUtils.java(86):accept: initData AbsolutePath /mnt/udisk2/群星 - 北京祝福你.mp4
11-02 09:34:03.746 2469-2469/? D/RRIVI: VideoUtils.java(86):accept: initData AbsolutePath /mnt/udisk2/少女时代的-My Oh My.mp4
11-02 09:34:03.746 2469-2469/? D/RRIVI: VideoUtils.java(86):accept: initData AbsolutePath /mnt/udisk2/Lady.GaGa.-.Poker.Face.avi
11-02 09:34:03.747 2469-2469/? D/RRIVI: VideoUtils.java(86):accept: initData AbsolutePath /mnt/udisk2/mv_少女时代 - Gee.rmvb
11-02 09:34:03.747 2469-2469/? D/RRIVI: VideoPlayerActivity.java(330):initData: initData /mnt/udisk2/Lady.GaGa.-.Poker.Face.avi; mCurPosition 4
Android 解析标准的点击第三方文件管理器中的视频的intent的更多相关文章
- Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程)
Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程) 看到网上AS3.0新增加的查看手机文件的新功能,全部都是转载的,没有几个人心细的把如何打开 ...
- 在Windows操作系统的文件管理器中集成Azure DevOps Server (TFS)工具菜单
故事场景 使用过SVN的用户,都知道在Windows的文件夹上点击鼠标右键,就会弹出Tortoise SVN的操作菜单(俗称小乌龟).通过这个功能,用户不需要打开SVN工具,可以直接在Windows的 ...
- eclipse 怎么 直接查看 文件所在位置 显示在文件管理器中。用浏览器浏览。
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha eclipse 怎么 直接查看 文件所在位置 显示在文件管理器中.用浏览器浏览.
- Android为TV端助力 集成第三方播放器,实现全屏播放
下面这Demo链接:Android实现全屏播放,各种格式支持直播,点播,不收费!
- android混淆打包配置(忽略第三方jar)
在project.properties里加上 proguard.config=proguard.cfg proguard.cfg 配置如下: -optimizationpasses 5-dontu ...
- 免费的在线Web文件管理器:Net2FTP,Pydio,eXtplorer,KodExplorer–功能强大
https://www.freehao123.com/web-ftp/ 经常有朋友在使用一些没有带文件管理器的空间时,苦于没有办法来解压上传的文件压缩包,而如果不先上传压缩包,直接上传文件夹的话耗费的 ...
- [转帖]使用Gnome文件管理器连接到服务器:FTP/SFTP、Samba、NFS的方法
使用Gnome文件管理器连接到服务器:FTP/SFTP.Samba.NFS的方法 2019-05-09 16:28:44作者:雷增线稿源:云网牛站 https://ywnz.com/linuxyffq ...
- Android中调用文件管理器并返回选中文件的路径
实际项目中经常需要调用文件管理器,选择下载路径或者上传的本地文件路径.今天就给大家做个demo示范该功能的实现过程. 一.实现效果预览 以下为三星S6的样机测试效果,当然不同手机调用后的效果不一样. ...
- Android解析编译之后的所有文件(so,dex,xml,arsc)格式
我们在之前一篇一篇介绍了如何解析Android中编译之后的所有文件格式,所有的工作都完成了,这里我们就来做个总结,我们为什么要做这些工作: 第一篇:解析so文件格式 点击进入 这里我们解析so文件,主 ...
随机推荐
- [Swift]LeetCode316. 去除重复字母 | Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter ...
- Python基础语法(三)
Python基础语法(三) 1. 数值型数据结构 1.1 要点 在之前的博客也有提到,数值型数据结构在这里就不过多介绍了.在这里提及一些需要知道的知识点. int.float.complex.bool ...
- Redis 设计与实现 (四)--事件、客户端
事件 一.文件事件 文件事件处理器使用I/O多路复用程序来同时监听多个套接字, 监听套接字,分配对应的处理事件. 四个组成部分:套接字 .I/O多路复用 . 文件事件分派器 . 事件处理器 连接应答处 ...
- 关于datagrid中控件利用js调用后台方法事件的问题
前台调用后台方法除了用button的click事件,还可以用js调用 一.前台页面如图 需求点击这个按钮触发后台事件,从而能够调用存储过程 <epoint:HyperLinkColumn He ...
- C#基础语法
究极入门之Hello world static void Main(string[] args) { //你好,世界 Console.WriteLine("HELLO WORLD" ...
- 如何写好css系列之button
现代前端行业的发展,如果你在css的时候,还没有利用一些预编译工具,是否觉得自己太low了.但你是否考虑过搭建一套自己前端框架.可能你会想这是否有必要,因为基础有boostrap,组件库有:easyu ...
- directshow、 Emgucv入门
本示例主要测试了directshow.Emgucv的视频流采集功能,其中Emgucv还实现了人脸的识别.示例源码下载 一.directshow的介绍 实现原理:directshow可以将摄像头的数据流 ...
- ThreadPoolExecutor线程池任务执行失败的时候会怎样
接上一篇 <JDK1.8中的线程池> 1. 任务执行失败时的处理逻辑 1.1. Worker Worker相当于线程池中的线程 可以看到,Worker有几个重要的属性: thread ...
- C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...
- .net core 使用ConcurrentTest组件对方法进行压力测试
工欲善其事,必先利其器!在编写服务中首先要有一个好的测试工具,在dontecore下性能测试有BenchmarkDotNet,只需要简单的配置一下就可以对方法的性能进行详细的测试.但有时候需要对不同并 ...