如题,球思路,怎么实现
------解决思路----------------------
声明:
private MediaPlayer player;
private SurfaceView surface;
private SurfaceHolder surfaceHolder;
实例化及相关动作:
surfaceHolder = surface.getHolder();// SurfaceHolder是SurfaceView的控制接口
surfaceHolder.addCallback(this);// 因为这个类实现了SurfaceHolder.Callback接口,所以回调参数直接this
surfaceHolder.setFixedSize(320, 220);// 显示的分辨率,不设置为视频默认
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);// Surface类型
这是实现surfaceholder接口时要做的动作:
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDisplay(surfaceHolder);
player.setLooping(true);
try {
player.setDataSource("/sdcard/ascleft_tool/back.mp4");
player.prepare();
} catch (Exception e) {
e.printStackTrace();
}
player.start();
}
不用谢我,我叫红领巾