我想從服務器播放mp4格式和大小4-5Mb視頻流模式。我使用sdk版本2.3,在模擬器上它 只給出聲音,但沒有任何圖片。從服務器播放Mp4視頻android
我還在設備Samsung(android sdk ver 2.1)和LG optimus(android sdk ver 2.2) 上測試過它,只能得到「無法播放視頻:抱歉,此視頻無法流式傳輸到此設備」消息。 我已經搜索了這個,但沒有得到任何解決方案,如果任何人有任何解決方案,請幫助我。提前感謝。
這裏是我的代碼:
public class ShowVideo extends Activity
{
private static ProgressDialog progressDialog;
public String video_url;
private MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.videoalbum);
progressDialog = ProgressDialog.show(ShowVideo.this, "", "Buffering video...", true);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4";
try {
final VideoView videoView =(VideoView)findViewById(R.id.video_viewId);
mediaController = new MediaController(ShowVideo.this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format)
Uri video = Uri.parse(video_url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
videoView.start();
}
});
}catch(Exception e){
progressDialog.dismiss();
System.out.println("Video Play Error :"+e.getMessage());
}
}
感謝efeyc您reply.I已在名爲.3gp格式轉換的MP4這些視頻和它們工作正常。 – sachin003 2011-09-12 10:18:34