Play movie.m4v file : MediaPlayer « Media « Android






Play movie.m4v file

    
package app.test;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;

public class Test extends Activity implements View.OnClickListener {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Button button = new Button(this);
        button.setOnClickListener(this);
        setContentView(button);
    }
    
    @Override
    public void onClick(View v) {
        
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse("file:///android_asset/movie.m4v"), "video/h264");
        startActivity(Intent.createChooser(intent, "Play Video"));
    }
}

   
    
    
    
  








Related examples in the same category

1.Using MediaPlayer to play MP3 file
2.MediaPlayer and Text to Speech
3.Load mp3 file with MediaPlayer and play
4.Call prepare for MediaPlayer before starting
5.Set URL data source for MediaPlayer
6.Audio MediaPlayer Demo
7.Using MediaPlayer to play Video and Audio
8.extends MediaPlayer
9.MediaPlayer create and start
10.Multi PlayMixer
11.Using Service to play media file