I have a VideoView that takes up the top half of the Activity in portrait orientation with the bottom half of the screen showing some images and text. I am playing a rtsp v
this is the first time I answer a question in stackoverflow, I only insert a VideoView inside a FrameLayout with same measures both. MediaController will be at the bottom of the FrameLayout. This worked for me:
main_activity.XML:
MainActivity.java:
@Override
public void onClick(View v) {
int i = v.getId();
if(i == R.id.select_video){
selectVideo();
}
private void selectVideo(){
//this code is to get videos from gallery:
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("video/*");
startActivityForResult(galleryIntent, GALLERY_REQUEST);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(mVideo);
//mVideo is the VideoView where I insert the video
mVideo.setMediaController(mediaController);
mVideo.pause();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case 1:
if (resultCode == RESULT_OK) {
mVideoUri = data.getData();
mVideo.setVideoURI(mVideoUri);
mVideo.start();
}
}
}