Android中除了利用VideoView、Mediaplayer播放视频文件外,还可以用发送Intent来调用视频播放模块。
16lz
2021-01-23
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!
更多相关文章
- Android Browser学习八 书签历史模块: 历史UI的实现
- 为Android扩展一个硬件模块需要做两件事:
- 如何掌握Android-Camera模块
- 【Android 多模块构建】如何启动另外一个module中的Activity
- Wifi模块分析_android
- android 浏览器 内容区 内嵌 scroll 不能滚动解决
- 六种最具视觉效果的Android(安卓)手机浏览器
- Android帧缓冲区(Frame Buffer)硬件抽象层(HAL)模块Gralloc的实现原
- Android Wifi模块分析(四)