LoginSignup
4
4

More than 5 years have passed since last update.

androidでresディレクトリに設置した動画ファイルの再生コード。

Last updated at Posted at 2012-03-16

予めlayout.xmlでviewoViewを追加しておきます。

ただしapkの容量制限(16MB?)があるため、それほど大きな動画ファイルをapk内に設置するのは無理があるので、アプリケーション起動後、WEBから落とすかが必要と思います。

VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
Uri videopath = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.*****);
videoView.setVideoPath(videopath);

再生が完了した時の動作は、OnCompletionListenerを実装する。

@Override
public void onCompletion(MediaPlayer mp) {
    // TODO Auto-generated method stub
    mp.seekTo(0);
    mp.start();
}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4