当前位置: 首页 > 工具软件 > ActionView > 使用案例 >

Android VideoView通过Intent.ACTION_VIEW播放视频(4)

卫飞
2023-12-01
Android VideoView通过Intent.ACTION_VIEW播放视频(4)

Android VideoView播放视频的方式不唯一,简单、轻量级的播放技术路线是通过调用系统接口Intent.ACTION_VIEW设置参数播放,如下面的代码所示:
Intent intent=new Intent();
		intent.setAction(Intent.ACTION_VIEW);
		//SDCard卡根目录下/DCIM/Camera/test.mp4文件
		Uri uri=Uri.parse("file:///sdcard/DCIM/Camera/test.mp4");
		intent.setDataAndType(uri, "video/*");
		startActivity(intent);

记得要增加读写外部存储的权限。


附录参考文章:
【1】《Android VideoView播放视频(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/49885697
【2】《Android VideoView播放在线视频(2)》链接地址:http://blog.csdn.net/zhangphil/article/details/49885995
【3】《Android VideoView播放视频控制:开始、暂停、快进(3)》链接地址:http://blog.csdn.net/zhangphil/article/details/49886543
 类似资料: