Skip to main content
Skip table of contents

Video scaling modes

The CONNECT Player for Android SDK attempts to fit the playback video with the maximum possible size within the boundaries of the OTVVideoView you have created. Under normal circumstances, given the width and the height of the container view, the player stretches the width and the height of the playback video to the view's boundaries while maintaining the video's aspect ratio. The consequences of this are that if the aspect ratio of the OTVVideoView instance is narrower than that of the content's, black bands are shown above and below the playback; if it is wider, the black bands appear to the right and left of the video playback. This behaviour is called the scale to fit scaling mode.

A typical aspect ratio for video content is 16:9. However, some modern phone screens, in landscape orientation, host an aspect ratio of 18:9. The result is that black margins appear to the sides of the video, and not all of the screen size is utilised. In such cases (and any other instances in which there is an aspect ratio mismatch), you may prefer to scale-up the picture to the full size of the video view at the expense of some of the picture. Such scaling is called scale to fit with cropping mode. In the case of 16:9 vs 18:9 (in landscape orientation), the picture covers the entire view with the top and bottom of the picture being cropped.

The CONNECT Player for Android SDK provides the option to select which mode you prefer. By default, non-cropping mode is selected.

Example code

OTVVideoView has a public API that lets you configure this feature by specifying the video scaling mode any time after the video source URL is specified:

JAVA
public void setVideoScalingMode(int mode)

The supported mode values are (self-explanatory):

JAVA
MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT
MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING

So, a typical implementation would look like the following:

JAVA
// Creating VideoView
OTVVideoView videoView = new OTVVideoView(this);
...

// Setting-up the content source
videoView.setVideoPath(url);

...

// Setting-up the scaling mode
videoView.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);

...

The video mode will now persist even if you perform zapping by specifying a new URL:

JAVA
// Setting-up the content source
videoView.setVideoPath(url);

However, if the OTVVideoView instance is destroyed, the scaling mode needs to be set again.

The scale to fit with cropping mode remains enabled even after resizing the view, for example, when rotating. Your application must disable this mode (restoring to the scale to fit mode) in such scenarios.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.