Skip to main content

Native Video Ad

info

Outstream ads are supported starting from NAMSDK version 6.2.0.

info

Starting from NAMSDK version 7.3.0, you can choose the UI for Outstream ads.

Native Integration Guide

Outstream is a Native Normal type ad. For the Native Normal integration guide, please refer to the link.

Outstream Player UI

Outstream ads display video within a MediaView.

To configure the control UI for Outstream, refer to the GFPVideoOptions viewType guide. If you want to build a custom control UI per publisher, refer to the useCustomControlView guide.

Outstream API

enableMediaBackgroundBlur

Sets whether to apply a blur effect to the margin area of the native ad media view. (Default: NO) The blur is applied only when a thumbnail image is available. If no thumbnail exists, a black background is displayed instead.

let nativeOptions = GFPAdNativeOptions()

let renderingSetting = GFPNativeAdRenderingSetting()
renderingSetting.enableMediaBackgroundBlur = false
renderingSetting.enableMediaBackgroundBlur = true

nativeOptions.renderingSetting = renderingSetting

GFPVideoOptions

Use GFPVideoOptions to configure the playback policy, whether to use a custom control view, and the maximum video quality for Outstream ads.

GFPVideoOptions is passed by setting it on the adLoader's nativeOptions.

let nativeOptions = GFPAdNativeOptions()

let videoOption = GFPVideoOptions(playPolicy: .autoPlay, useCustomControlView: false)

nativeOptions.videoOptions = videoOption

GFPVideoPlayPolicy

Sets the playback policy for the ad video. (Default: Auto)

  • Auto: The SDK controls video playback directly. The video plays to the end when the network is WiFi or Cellular.
  • Auto Only WiFi: The SDK controls video playback directly. The video plays to the end only when the network is WiFi. On Cellular, playback stops after n seconds.
  • Manual: The service controls video playback. When the ad is displayed, the video appears in a paused state, and the service determines when to begin playback.
let videoOption = GFPVideoOptions(playPolicy: .autoPlay, useCustomControlView: false)

let videoOption = GFPVideoOptions(playPolicy: .autoPlayOnlyWiFi, useCustomControlView: false)

let videoOption = GFPVideoOptions(playPolicy: .manual, useCustomControlView: false)

useCustomControlView

Sets whether to use a custom control view for the ad video. (Default: NO) When set to YES, the player's control elements are hidden. When set to NO, the SDK renders the control elements internally.

let videoOption = GFPVideoOptions(playPolicy: .autoPlay, useCustomControlView: false)

let videoOption = GFPVideoOptions(playPolicy: .autoPlay, useCustomControlView: true)

maxBitrateKbps

Sets the maximum bitrate for the ad video. (Default: 800, unit: kbps)

videoOption.maxBitrateKbps = 800

viewType (since 7.3.0)

viewTypedescription
DefaultTapping the video screen shows control buttons.Sample image
LandingTapping the video screen navigates to the advertiser's site.Sample image
let videoOptions = GFPVideoOptions(playPolicy: .autoPlay, viewType: .default)

let videoOptions = GFPVideoOptions(playPolicy: .autoPlay, viewType: .landing)

GFPMediaData

Native Normal type ads are delivered via adLoader:didReceiveNativeAd:. For more details on GFPAdLoaderDelegate, refer to the link.

You can retrieve information rendered in the MediaView through nativeAd.mediaData.

let mediaData = nativeAd.mediaData

mediaType

You can identify the ad type through mediaType.

  • GFPMediaTypeImage: Image type
  • GFPMediaTypeVideo: Video type
  • GFPMediaTypeRichMedia: Rich media type such as special DA at the bottom of search results
  • GFPMediaTypeUnknown: Ads served via C2S through Google, Meta, InMobi, etc.
let mediaType = nativeAd.mediaData.mediaType

aspectRatio

Provides the aspect ratio of the media. Returns -1 if the data is not available.

let aspectRatio = nativeAd.mediaData.aspectRatio

videoController

Returned only when mediaType is Video. Returns nil if the data is not available.

let videoController = nativeAd.mediaData.videoController

GFPVideoController

Through videoController, you can obtain information such as progressInfo and isMuted, and control video playback including mute/play/pause/stop.

progressInfo

Provides the duration, currentTime, and bufferedTime of the ad video.

let videoController = nativeAd.mediaData.videoController

let progressInfo = videoController.progressInfo

let duration = progressInfo.duration
let currentTime = progressInfo.currentTime
let bufferedTime = progressInfo.bufferedTime

isPlaying

Indicates whether the ad video is currently playing.

let videoController = nativeAd.mediaData.videoController

let isPlaying = videoController.isPlaying

enableControl

Indicates whether control of the ad video is available. enableControl is related to GFPVideoPlayPolicy.

  • When the playPolicy of videoOptions is Manual: enableControl returns YES.
  • When the playPolicy of videoOptions is not Manual: enableControl returns NO.
let videoController = nativeAd.mediaData.videoController

let enableControl = videoController.enableControl

preferredForwardBufferDuration

Sets the preferredForwardBufferDuration for the ad video.

let videoController = nativeAd.mediaData.videoController
videoController.preferredForwardBufferDuration = 0

mute

Sets the mute state of the ad video. The mute state can be queried via isMuted.

let videoController = nativeAd.mediaData.videoController

videoController.mute = true
videoController.mute = false

let isMute = videoController.isMuted

play

Plays the ad video. Only works when enableControl is YES.

let videoController = nativeAd.mediaData.videoController
videoController.play()

pause

Pauses the ad video. Only works when enableControl is YES.

let videoController = nativeAd.mediaData.videoController
videoController.pause()

stop

Stops the ad video and resets it to the beginning. Only works when enableControl is YES.

let videoController = nativeAd.mediaData.videoController
videoController.stop()

seek:

Moves the ad video to a specific playback position. progress is passed as a value between 0.0 (start) and 1.0 (end). Only works when enableControl is YES.

let videoController = nativeAd.mediaData.videoController
videoController.seek(0.5) // Move to the 50% point of the video

GFPVideoEventDelegate

Can be set via the videoController's delegate to receive events for the ad video.

let videoController = nativeAd.mediaData.videoController
videoController.delegate = self

adPlayerDidPlay:

Called when the ad video starts playing.

func adPlayerDidPlay(_ videoController: GFPVideoController) {

}

adPlayerDidPause:

Called when the ad video is paused.

func adPlayerDidPause(_ videoController: GFPVideoController) {

}

adPlayerDidComplete:

Called when the ad video finishes playing.

func adPlayerDidComplete(_ videoController: GFPVideoController) {

}

adPlayerDidChangeMuteState:

Called when the mute state of the ad video player changes.

func adPlayerDidChangeMuteState(_ videoController: GFPVideoController) {

}

adPlayer:didChangeCurrentTime:

Called when the current playback progress of the ad video changes.

func adPlayer(_ videoController: GFPVideoController, didChangeCurrentTime currentTime: TimeInterval) {

}

adPlayer:didChangeBufferedTime:

Called when the buffered progress of the ad video changes.

func adPlayer(_ videoController: GFPVideoController, didChangeBufferedTime bufferedTime: TimeInterval) {

}

adPlayer:didTappedControlButton:

(Optional) Called when a control button in the native ad video is tapped. This is called when using the default controlView provided by the SDK, and is not called when using a customControlView.

func adPlayer(_ videoController: GFPVideoController, didTappedControlButton buttonType: GFPControlButtonType) {

}