ポイント
(1)SurfaceView, SurfaceHolder.Callback, Mediaplayerを利用する
http://into.cocolog-nifty.com/pulog/2011/11/android041-1med.html
(2).mp4をres以下に保存する。エンコーディングはffmpegを使ってbaselineprofile?に変換しておく
http://stackoverflow.com/questions/14709447/android-play-local-video-with-mediaplayer
http://stackoverflow.com/questions/10849044/cant-play-mp4-video-in-my-android-app
ffmpeg -i yourfile.mp4 -c:v libx264 -profile:v baseline -level 1 yourfile_BaselineProfile.mp4
import android.app.Activity; import android.graphics.PixelFormat; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; public class MainActivity extends Activity implements SurfaceHolder.Callback{ private SurfaceHolder holder; private SurfaceView surfaceView; private MediaPlayer mMediaPlayer = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button playBtn = (Button) findViewById(R.id.playBtn); getWindow().setFormat(PixelFormat.TRANSPARENT); surfaceView = (SurfaceView) findViewById(R.id.surfaceView); holder = surfaceView.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); holder.addCallback(this); playBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { String path = "android.resource://" + getPackageName() + "/" + R.raw.baselineprofile; mMediaPlayer = MediaPlayer.create(MainActivity.this, Uri.parse(path)); mMediaPlayer.setDisplay(holder); mMediaPlayer.start(); } catch (Exception e) { android.util.Log.e("", e.toString()); } } }); } @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { } @Override public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) { } @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { if(mMediaPlayer != null){ mMediaPlayer.release(); mMediaPlayer = null; } } }