如何播放SD卡中的视频 [英] How to play videos from SD Card

查看:1032
本文介绍了如何播放SD卡中的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的应用程序,它可以从网上流式传输视频,并且成功了,但是现在我想更改代码,以便可以播放SDCard中的视频文件

I was creating a simple app which stream videos from net and I made it but now I want to change the code so that I can play video files from my SDCard

原始代码:

Uri vidFile = Uri.parse("MY SITE HERE");
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
videoView.setVideoURI(vidFile);
videoView.setMediaController(new MediaController(this));
videoView.start();

因此,请帮助我更改代码,以便它可以播放移动存储卡中的视频.

So please help me with changing the code so that it can play videos from my mobile memory card.

推荐答案

videoView.setVideoURI(vidFile);方法需要替换为videoView.setVideoPath(path);方法. 此处的path指定SDCARD上视频文件的路径.

The videoView.setVideoURI(vidFile); method needs to be replaced by the videoView.setVideoPath(path); method. Here path specifies the path of the video file on the SDCARD.

使用该视频文件的MediaStore.Video.Media.DATA属性或仅以/sdcard/songname静态输入歌曲路径,即可轻松检索该路径.

This path can be easily retrieved using the MediaStore.Video.Media.DATA property of that video file or by just entering the songpath statically as /sdcard/songname.

这篇关于如何播放SD卡中的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆