Example usage for android.media MediaPlayer VIDEO_SCALING_MODE_SCALE_TO_FIT

List of usage examples for android.media MediaPlayer VIDEO_SCALING_MODE_SCALE_TO_FIT

Introduction

In this page you can find the example usage for android.media MediaPlayer VIDEO_SCALING_MODE_SCALE_TO_FIT.

Prototype

int VIDEO_SCALING_MODE_SCALE_TO_FIT

To view the source code for android.media MediaPlayer VIDEO_SCALING_MODE_SCALE_TO_FIT.

Click Source Link

Document

Specifies a video scaling mode.

Usage

From source file:com.lamcreations.scaffold.common.activities.VideoSplashScreenActivity.java

@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
    Surface s = new Surface(surface);

    try {/*from   ww  w .  java  2  s .c  om*/
        mMediaPlayer = MediaPlayer.create(this, getVideoRawResId());
        mMediaPlayer.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
        mMediaPlayer.setSurface(s);
        mMediaPlayer.setOnBufferingUpdateListener(this);
        mMediaPlayer.setOnPreparedListener(this);
        mMediaPlayer.setOnVideoSizeChangedListener(this);
        mMediaPlayer.setOnSeekCompleteListener(this);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mTextureView.setAspectRatio(mMediaPlayer.getVideoWidth(), mMediaPlayer.getVideoHeight());
    } catch (IllegalArgumentException | SecurityException | IllegalStateException e) {
        Log.d(TAG, e.getMessage());
    }
}