Video scaling modes

The OpenTV Player for Android SDK attempts to fit the playback video with the maximum possible size within the boundaries of the NMPVideoView 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 NMPVideoView 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 would 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 cases where there is an aspect ratio mismatch), the user/integrator 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 OpenTV Player for Android SDK provides you the option to select which mode you prefer. By default, the non-cropping mode is selected.

Example code

  • NMPVideoView 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:

     public void setVideoScalingMode(int mode)
  • The supported mode values are (self explanatory):

  • A typical implementation would look like the following:

    // Creating VideoView
    NMPVideoView videoView = new NMPVideoView(this);
    // Setting-up the content source
    // Setting-up the scaling mode
    //Starting VideoView
  • The video mode will now persist even if you perform zapping by specifying a new URL:

    // Setting-up the content source

    If the NMPVideoView instance is destroyed, the scaling mode needs to be set again.

    Scale to fit with cropping mode remains enabled even after resizing the view, for example when rotating. It is the responsibility of the integrator's application to disable this mode (restoring to the scale to fit mode) in such scenarios.