Android游戏开发学习笔记(三):视频的播放(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-25 11:34 点击:次
import android.graphics.PixelFormat;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements SurfaceHolder.Callback {
String path = "/sdcard/qtfy01.3gp";
Button play_btn, pause_btn;
boolean isPause = false;
SurfaceHolder surfaceHolder;
MediaPlayer mediaPlayer;
SurfaceView surfaceView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
play_btn = (Button) findViewById(R.id.play_btn);
play_btn.setOnClickListener(video_listener);
pause_btn = (Button) findViewById(R.id.pause_btn);
pause_btn.setOnClickListener(video_listener);
getWindow().setFormat(PixelFormat.UNKNOWN);
surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setFixedSize(176, 144);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mediaPlayer = new MediaPlayer();
}
private OnClickListener video_listener = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.play_btn:
isPause = false;
playVideo(path);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>