Rendering Video


The scaling of the rendered video is defined using UIView.ContentMode property of the VideoView, you may choose  between .scaleAspectFit , .scaleAspectFill or .scaleToFill .

The content mode for attaching video participants. The UIView.ContentMode property can be set on views individually after attaching. This will change how the video is rendered within the provided UIView. Setting the mode will only affect views attached after the default is set. The supported values are .scaleToFill, .scaleAspectFit, .scaleAspectFill.

setDefaultVideoContentMode(_ contentMode: UIView.ContentMode) can be used to choose a layout where videos maintain their aspect ratio but are cropped within their container, by setting the content mode to .scaleAspectFill. Alternatively, you can maintain the video aspect ratio with a clear space on the sides, or top and bottom by setting the content mode to .scaleAspectFit.

By default, it is .scaleAspectFit  (which means “pillar boxing”, or “letterboxing”). BlueJeans SDK allows you to render a video of your choice. If you want the entire video to fill the screen, you can switch to .scaleAspectFill. Use the following configuration to switch the .contentMode between .scaleAspectFit and .scaleAspectFill on double tap (when the videoDoubleTapped @IBAction is triggered).

 @IBAction func videoDoubleTapped(_ sender: Any) {
        if let currentVideoView = currentVideoView, currentVideoView.contentMode == .scaleAspectFit {
               currentVideoView.contentMode = .scaleAspectFit
            } else {
                currentVideoView?.contentMode = .scaleAspectFill
            }
    }

You should consider your layout and decide whether cropping or letterboxing is more appropriate for your use case. You can also observe the resolution of the stream and resize the container instead.