此代碼有什麼問題?
我在我的項目(MP4視頻文件),
原始文件,當我這樣做,然後我從SDcard文件retreive文件不相同,因此視頻無法加載:(
你有另一種方式全自動複製原始文件到SD卡?
感謝Android:將RawFile複製到SD卡(視頻MP4)
String FICHIER_BLOW = "blowvid4.mp4";
File f=new File(Environment.getExternalStorageDirectory(), FICHIER_BLOW);
try {
if (f.createNewFile()){
FileWriter ecrivain = new FileWriter(f);
BufferedWriter bufEcrivain = new BufferedWriter(ecrivain);
BufferedInputStream VideoReader = new BufferedInputStream(getResources().openRawResource(R.raw.blow));
while(VideoReader.available() > 0){
bufEcrivain.write(VideoReader.read());
}
bufEcrivain.close();
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
video =Uri.fromFile(f);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
根據softam的說明,您可能需要額外的flush() - 絕對是在BufferedOutputStream的情況下 – 2010-07-30 01:07:15