1
我試圖從SD卡播放視頻,我從eclipse的DDMS視圖中將視頻壓入mnt/sdcard文件夾。但是模擬器屏幕顯示爲空白,沒有任何錯誤。請幫助。從SD卡播放視頻文件
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
請告訴我有什麼區別?這將返回相同的字符串。它也不工作.. – Tanvir
sdcard文件夾可以不同。所以編程更好。而你的Uri不是類型文件:///。因此,使用編輯的代碼 – nandeesh
它如何不工作.. – Tanvir