Videoview resizing for video size

0

I have a problem in my application, in the app I make a sequence of videos, but at the time I made the structure and inserted the video (not very graphic quality so the app does not get too big) VideoView means resized and got very small, anyone have any idea how I can solve this? Yes I do not care if the video gets ugly if it gets pixilated.

<?xml version="1.0" encoding="utf-8"?>

<VideoView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/VV1"
    android:layout_weight="1" />

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_weight="0">




    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/btnVoltar"
        android:id="@+id/button2"
        android:layout_weight="2" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/btnAvanca"
        android:id="@+id/button3"
        android:layout_weight="2" />
</LinearLayout>

    
asked by anonymous 14.03.2016 / 00:41

1 answer

0

Good morning, I think it's possible to do this with VideoView but another option is to use SurfaceView: xml:

 < SurfaceView
        android:id="@+id/surface_view1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical" />

Activity:

public class MainActivity extends AppCompatActivity implements MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener,SurfaceHolder.Callback {

private MediaPlayer mediaPlayer;
private SurfaceView surfaceView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    surfaceView = (SurfaceView)findViewById(R.id.surface_view1);
   SurfaceHolder surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);
    MediaPlayer mediaPlayer   = new MediaPlayer();
    Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.big_buck_bunny);

    try {
        mediaPlayer.setDataSource(this,   videoUri);
        mediaPlayer.prepare();
    } catch (IOException e) {
        e.printStackTrace();
    }

    mediaPlayer.setOnErrorListener(this);
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
}



@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    Log.d(TAG, "onError() called with: " + "mp = [" + mp + "], what = [" + what + "], extra = [" + extra + "]");
    return false;
}

@Override
public void surfaceCreated(SurfaceHolder holder) {
    mediaPlayer.setDisplay(holder);
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {

}

@Override
public void onPrepared(MediaPlayer mp) {
    mp.start();
}
    
14.03.2016 / 13:26