Menu Home

视频

Android使用MediaPlayer播放视频步骤

MediaPlayer状态变换图: public class MainActivity extends Activity { Display display; SurfaceHolder surfaceHolder; SurfaceView surfaceView; MediaPlayer mediaPlayer; // 视频宽高 int width = 0; int height = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); display = getWindowManager().getDefaultDisplay(); String file = Environment.getExternalStorageDirectory() .getAbsolutePath() + “/Movies/1.m4v”; surfaceView = (SurfaceView) findViewById(R.id.sv); surfaceHolder = surfaceView.getHolder(); […]