android视频播放

先看代码: 
try { 
String path = "/sdcard/t.mp3"; 
MediaPlayer mp = null; 
mp = new MediaPlayer(); 
mp.setDataSource(path); 
mp.prepare(); 
mp.start(); 
mp.setOnCompletionListener(cl); 
} catch (IllegalArgumentException e) { 
e.printStackTrace(); 
} catch (IllegalStateException e) { 
e.printStackTrace(); 
} catch (IOException e) { 
e.printStackTrace(); 

音频播放,就是这么简单。 
视频播放用VideoView,也不是很复杂。 

我还是把代码加上吧,不然老感觉不完整。 
VideoView videoView = new VideoView(this); 
setContentView(videoView); 
videoView.setVideoURI(Uri.parse("/sdcard/t.3gp")); 
videoView.requestFocus(); 
videoView.start(); 

posted @ 2009-08-29 16:47  张兴业  阅读(134)  评论(0编辑  收藏  举报