Reputation: 1910
Suppose a user is Watching a video and taps on the screen, then a bar comes in the bottom of the screen containing Play ,Pause etc....what do we call such kind of BAR.. If possible a sample code showing the Bar when user taps on the screen will be very usefull.Thank u..
Upvotes: 0
Views: 128
Reputation: 1007379
what do we call such kind of BAR
That is a MediaController
.
If possible a sample code showing the Bar when user taps on the screen will be very usefull
OK, here you go. The activity in question is rather simple:
package com.commonsware.android.video;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;
import java.io.File;
public class VideoDemo extends Activity {
private VideoView video;
private MediaController ctlr;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
File clip=new File(Environment.getExternalStorageDirectory(),
"test.mp4");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}
}
Upvotes: 1