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/*";

Uriuri =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 Browser学习八 书签历史模块: 历史UI的实现
  2. 为Android扩展一个硬件模块需要做两件事:
  3. 如何掌握Android-Camera模块
  4. 【Android 多模块构建】如何启动另外一个module中的Activity
  5. Wifi模块分析_android
  6. android 浏览器 内容区 内嵌 scroll 不能滚动解决
  7. 六种最具视觉效果的Android(安卓)手机浏览器
  8. Android帧缓冲区(Frame Buffer)硬件抽象层(HAL)模块Gralloc的实现原
  9. Android Wifi模块分析(四)

随机推荐

  1. 改善用户体验
  2. android反编译工具 ApkDec-Release-0.1
  3. android Activity生命周期总结
  4. Android(安卓)- Error: "java.io.IOExcep
  5. Android触屏事件和MotionEvent详解
  6. Windows下的Android SDK下载,2.2之前各个
  7. android之Layout(一)
  8. Android Service生命周期及用法
  9. Android 启动页面优化 (白屏 、等待的问题
  10. 演化理解 Android(安卓)异步加载图片