解析标准的第三方视频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的更多相关文章

  1. Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程)

    Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程) 看到网上AS3.0新增加的查看手机文件的新功能,全部都是转载的,没有几个人心细的把如何打开 ...

  2. 在Windows操作系统的文件管理器中集成Azure DevOps Server (TFS)工具菜单

    故事场景 使用过SVN的用户,都知道在Windows的文件夹上点击鼠标右键,就会弹出Tortoise SVN的操作菜单(俗称小乌龟).通过这个功能,用户不需要打开SVN工具,可以直接在Windows的 ...

  3. eclipse 怎么 直接查看 文件所在位置 显示在文件管理器中。用浏览器浏览。

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha eclipse 怎么 直接查看 文件所在位置 显示在文件管理器中.用浏览器浏览.

  4. Android为TV端助力 集成第三方播放器,实现全屏播放

    下面这Demo链接:Android实现全屏播放,各种格式支持直播,点播,不收费!

  5. android混淆打包配置(忽略第三方jar)

    在project.properties里加上   proguard.config=proguard.cfg proguard.cfg 配置如下: -optimizationpasses 5-dontu ...

  6. 免费的在线Web文件管理器:Net2FTP,Pydio,eXtplorer,KodExplorer–功能强大

    https://www.freehao123.com/web-ftp/ 经常有朋友在使用一些没有带文件管理器的空间时,苦于没有办法来解压上传的文件压缩包,而如果不先上传压缩包,直接上传文件夹的话耗费的 ...

  7. [转帖]使用Gnome文件管理器连接到服务器:FTP/SFTP、Samba、NFS的方法

    使用Gnome文件管理器连接到服务器:FTP/SFTP.Samba.NFS的方法 2019-05-09 16:28:44作者:雷增线稿源:云网牛站 https://ywnz.com/linuxyffq ...

  8. Android中调用文件管理器并返回选中文件的路径

    实际项目中经常需要调用文件管理器,选择下载路径或者上传的本地文件路径.今天就给大家做个demo示范该功能的实现过程. 一.实现效果预览 以下为三星S6的样机测试效果,当然不同手机调用后的效果不一样. ...

  9. Android解析编译之后的所有文件(so,dex,xml,arsc)格式

    我们在之前一篇一篇介绍了如何解析Android中编译之后的所有文件格式,所有的工作都完成了,这里我们就来做个总结,我们为什么要做这些工作: 第一篇:解析so文件格式 点击进入 这里我们解析so文件,主 ...

随机推荐

  1. Hadoop 数据去重

    数据去重这个实例主要是为了读者掌握并利用并行化思想对数据进行有意义的筛选.统计大数据集上的数据种类个数.从网站日志中计算访问等这些看似庞杂的任务都会涉及数据去重.下面就进入这个实例的MapReduce ...

  2. Java面试题中常考的容易混淆的知识点区别

    以下是我收集的Java编程里各种区别,供Java学习爱好者参考,这些区别都是每次Java面试中常考的,大家好好掌握,如有失误请留言指出.想要获取Java详细全套学习资料请到上海尚学堂官网获取. 1.H ...

  3. [Swift]LeetCode386. 字典序排数 | Lexicographical Numbers

    Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,1 ...

  4. [Swift]LeetCode976. 三角形的最大周长 | Largest Perimeter Triangle

    Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, ...

  5. [Swift]LeetCode1018. 可被 5 整除的二进制前缀 | Binary Prefix Divisible By 5

    Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a bi ...

  6. 关于datagrid中控件利用js调用后台方法事件的问题

    前台调用后台方法除了用button的click事件,还可以用js调用  一.前台页面如图 需求点击这个按钮触发后台事件,从而能够调用存储过程 <epoint:HyperLinkColumn He ...

  7. Integer简介

    // 当创建范围为[-128,127]时 Integer a = ; Integer b = ; Integer c = ); System.out.println("a == b :&qu ...

  8. Oracle绝对秒数转换为时间戳

    一般Oracle得到的时间格式为: 1970-01-05 01:23:56.297 为了计算两个时间的差值: 1970-01-05 01:23:56.297 与 1970-01-05 01:24:57 ...

  9. MetaEditor中MQL使用方法

    MT4程序--帮助--MQL5文档,转到网页,切换到中文,点击旁边搜索图标. MetaEditor编辑器,点击相应关键字,按F1键,即可启动MT4对应的MQL4的对应关键字用法帮助.但是英文. 时间序 ...

  10. sql server 性能调优之 死锁排查

    一.概述 记得以前客户在使用软件时,有偶发出现死锁问题,因为发生的时间不确定,不好做问题的重现,当时解决问题有点棘手了.现总结下查看死锁的常用二种方式. 1.1 第一种是图形化监听: sqlserve ...