调用android 1.5的api可以播放mp4封装格式中的部分编码格式。

程序运行效果:

 image_thum34224cb5.png  

 

主要是调用android的媒体支持API,源代码:

package com.easymorse;

import android.app.Activity; 
import android.net.Uri; 
import android.os.Bundle; 
import android.widget.MediaController; 
import android.widget.VideoView;

public class Mp4PlayerActivity extends Activity {

    VideoView videoView;

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main);

        videoView = (VideoView) this.findViewById(R.id.videoView); 
        MediaController controller = new MediaController(this); 
        this.videoView.setMediaController(controller); 
        videoView.setVideoURI(Uri.parse("http://sayedhashimi.com/downloads/android/movie.mp4"));
        videoView.requestFocus(); 
    } 
}

这里使用的mp4是《pro android》电子版中的示例。播放成功。但是发现其他mp4无法播放。原因是android 1.5 api尚不支持h.264编码。上面示例的视频编码格式divx。

见mplayer播放的属性:

 image_thumb6.png  

源代码见:

http://easymorse.googlecode.com/svn/tags/mp4player_0.1m1

 
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()