1

我正在尝试从 SD 卡播放视频,我已经从 Eclipse 中的 DDMS 视图将视频推送到 mnt/sdcard 文件夹中。但是模拟器屏幕显示空白,没有任何错误。请帮忙。

public class Video extends Activity {
private MediaController mc;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    videoPlayer("mnt/sdcard","bikekid",true);
}


public void videoPlayer(String path, String fileName, boolean autoplay){
    //get current window information, and set format, set it up differently, if you need some special effects
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    //the VideoView will hold the video
    VideoView videoHolder = new VideoView(this);
    //MediaController is the ui control howering above the video (just like in the default youtube player).
    videoHolder.setMediaController(new MediaController(this));
    //assing a video file to the video holder
    videoHolder.setVideoURI(Uri.parse(path+"/"+fileName));
    //get focus, before playing the video.
    videoHolder.requestFocus();
    if(autoplay){
        videoHolder.start();
    }

 }

}/// end class
4

1 回答 1

0

利用

.getAbsolutePath() 

代替"mnt/sdcard"

编辑:

用这个

File file = new File(Environment.getExternalStorageDirectory(),"bikekid");
Uri mUri = Uri.fromFile(fie);
videoHolder.setVideoURI(mUri);
于 2012-09-14T12:26:57.687 回答