方法如下:
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中播放视频文件的多种方法,包括使用VideoView、MediaPlayer,以及通过发送Intent调用视频播放模块。详细说明了如何播放本地和网络视频,并强调了设置正确MIME类型的重要性。
5627

被折叠的 条评论
为什么被折叠?



