0

I want to resize my video and show it in the video view and maintain the quality of the video also, my main focus is that the video quality should not be harmed and it should be shown in the video view

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        VideoView videoView= (VideoView)findViewById(R.id.videoViewR);

      Video v=new Video();

        MediaController mc= new MediaController(this);
        mc.setAnchorView(videoView);

        Uri uri=Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/eveq.3gp");          
        videoView.setMediaController(mc);  
        videoView.setVideoURI(uri);          
        videoView.requestFocus();  
        videoView.start();    
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}

and my xml is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_vertical" >

    <VideoView
        android:id="@+id/videoViewR"
        android:layout_width="wrap_content"
        android:layout_height="480dp"
        android:layout_centerVertical="true" >

    </VideoView>

</RelativeLayout>

1 Answers1

0

If I understand your question then you don't have to do any special programming to resize the video to your VideoView. Let the MediaController and VideoView do all the scaling work for you.

First, your VideoView seems unusual (Why is height spec'd as 480 when the relative layout is only 270?). I'd suggest changing your VideoView to something like this:

<VideoView
    android:id="@+id/videoViewR"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="0dp"
    android:layout_marginLeft="0dp"
    android:layout_marginRight="0dp"
    android:layout_marginBottom="0dp"
    android:adjustViewBounds="true"
    android:scaleType="center" />

This will make the VideoView expand to the space available in the RelativeLayout and will adjust the bounds automatically.

Then the RelativeLayout should be as large as possible or the size you want (480x270 ?). To fill the space try

android:layout_width="match_parent"
android:layout_height="match_parent"

This will grow the layout to fill the space. Your video will then be scaled to fit these boundaries.

Hankster
  • 422
  • 3
  • 9
  • now i updated the relative layout, but i want the video view size remains constant as given but the video played in it must must get fit according to it......thanks – kishan Kataria May 20 '15 at 05:15
  • @Hankster i m following your answer but i m doing in java code in landcape i want match aprent width and height of video so i done the same but still its not working perfectly – Erum Sep 18 '15 at 07:03