Ниже мой код:
package com.example.videoplayer;
import android.app.Activity;
import android.app.ProgressDialog;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.MediaController;
import android.widget.VideoView;
public class VideoPlayerActivity extends Activity {
String TAG = "com.example.VideoPlayer";
ProgressDialog progDailog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_player);
final VideoView videoView = (VideoView) findViewById(R.id.videoView1);
videoView.setVideoPath("http://www.ebookfrenzy.com/android_book/movie.mp4");
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setOnPreparedListener(new
MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
progDailog.dismiss();
Log.i(TAG, "Duration = " + videoView.getDuration());
}
});
videoView.start();
progDailog = ProgressDialog.show(this, "Please wait ...", "Retrieving data ...", `enter code here`true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.video_player, menu);
return true;
}
}