解析标准的第三方视频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. Java编程题: 写一个Singleton出来

    Singleton模式主要作用是保证在Java应用程序中,一个类Class只有一个实例存在. 一般Singleton模式通常有几种种形式: 第一种形式:  定义一个类,它的构造函数为private的, ...

  2. [Swift]LeetCode333. 最大的二分搜索子树 $ Largest BST Subtree

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...

  3. [Swift]LeetCode392. 判断子序列 | Is Subsequence

    Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...

  4. [Swift]LeetCode437. 路径总和 III | Path Sum III

    You are given a binary tree in which each node contains an integer value. Find the number of paths t ...

  5. [Swift]LeetCode628. 三个数的最大乘积 | Maximum Product of Three Numbers

    Given an integer array, find three numbers whose product is maximum and output the maximum product. ...

  6. 记录eclipse安装SpringBoot插件及搭建SpringBoot项目

    刚学习了下SpringBoot 插件安装 创建项目在此记录下 在spring官网上下载相关的插件,然后导入到eclipse中,以下是下载步骤: 1.首先查看自己eclipse版本号 help--> ...

  7. nginx替换响应头(重点:如何在替换时加上if判断)

    在实现微信小程序内嵌非业务域名时,通过nginx做镜像网站绕过小程序业务域名检测,但有一些表单页面提交后会返回一个302状态,由响应头Location的值决定提交成功后的跳转地址.那么问题来了,这个地 ...

  8. 『ice 离散化广搜』

    ice(USACO) Description Bessie 在一个冰封的湖面上游泳,湖面可以表示为二维的平面,坐标范围是-1,000,000,000..1,000,000,000. 湖面上的N(1 & ...

  9. Elasticsearch Search API

    当执行一个搜索时,它将这个搜索请求广播给所有的索引分片.可以通过提供路由参数来控制要搜索哪些分片.例如,当检索tweets这个索引时,路由参数可以设置为用户名: curl -X POST " ...

  10. RabbitMQ消息队列(五)-安装amqp扩展并订阅/发布Demo(.Net Core版)

    publish发布消息 新建一个Asp.Net Core控制台项目:PublishDemo 安装Nuget包 Install-Package RabbitMQ.Client 添加命名空间引用 usin ...