Android中除了利用VideoView、Mediaplayer播放视频文件外,还可以用发送Intent来调用视频播放模块。

方法如下:

1.播放本地视频

        Intent intent = new Intent(Intent.ACTION_VIEW);

        String type = "video/mp4";
        Uri uri = Uri.parse("file:///sdcard/test.mp4");
        intent.setDataAndType(uri, type);
        startActivity(intent);

2.播放网络视频

        Intent intent = new Intent(Intent.ACTION_VIEW);

        String type = "video/* ";

   Uri uri = Uri.parse("http://forum.ea3w.com/coll_ea3w/attach/2008_10/12237832415.3gp");
        intent.setDataAndType(uri, type);
        startActivity(intent);

注意红色部分,如果不设置type的话,这样写:

       Intent intent = new Intent(Intent.ACTION_VIEW);

  Uri uri = Uri.parse("http://forum.ea3w.com/coll_ea3w/attach/2008_10/12237832415.3gp");
       intent.setData (uri);
       startActivity(intent);  

这样会默认用浏览器打开这个URL!

更多相关文章

  1. Android(安卓)Preference置灰显示
  2. 使用Javaweb开发的WebService部署到Tomcat,使用Android调用的遇到
  3. JNI基础实验一:调用.so文件--友善之臂Tiny210 android 串口/pwm/A
  4. Android下打印调用栈
  5. Android热插拔事件处理流程
  6. Android调用相机接口
  7. android binder机制
  8. [置顶] Android下实现自动关机的方法总结
  9. Android之WebView 防止调用系统浏览器打开页面

随机推荐

  1. Android(安卓)中把Activity当作Dialog来
  2. How Android(安卓)Handles Touches
  3. Android:ThreadLearning1
  4. Android(安卓)CrashManager
  5. Android(安卓)Multi-Core Enable/Disable
  6. Android(安卓)Security Overview
  7. ContentProvider示例-Calendar Provider
  8. Android-GeoQuiz
  9. 摇一摇监听器
  10. android Handler消息处理源码剖析