zoukankan      html  css  js  c++  java
  • android开发里跳过的坑——调用已安装视频播放器在有些机器上无效

    调用已安装视频播放器播放未修改之前的代码

    private void startPlay(String fileName){
        File file = new File(fileName);
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        String type = "video/*";
        Uri uri = Uri.parse(file.getAbsolutePath());
        intent.setDataAndType(uri, type);
        startActivity(intent);
    }

    在三星的一台4.2的手机上测试没有问题,但是在小米系列手机上,无法启动播放器,做如下修改后,所有手机上正常

    private void startPlay(String fileName){
       // File file = new File(fileName);
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        String type = "video/*";
        Uri uri = Uri.parse("file://" + fileName);//-----modify here
        intent.setDataAndType(uri, type);
        startActivity(intent);
    }


    所以,URI这部分一定要记得加头!

  • 相关阅读:
    jquery 不支持$.browser
    js 双向绑定
    css3 省略号
    js生成txt文件
    Browser-sync
    Generator & yield write in sync way
    Charles
    缓动函数与动画
    让Safari使用Chrome的代理
    React 同构
  • 原文地址:https://www.cnblogs.com/suxiaoqi/p/6737444.html
Copyright © 2011-2022 走看看