※ Currently video advertisements can only be used by limited partners
RFPPlayerControl
In the case of a video advertisement, RFPInstreamInfoModel.isVideo()
is returned as true
. This can be used to judge whether it is a video advertisement or not.
There are two RFPInstreamAdLoaderDelegate methods used with video advertising.
viewControllerForPresentingModalView
readyToPlay(with playerControl: RFPPlayerControl!)
playerControl.play()
is executed before preparations are complete.instreamAdLoader.getVideoControl(withFrame:infoModel:)
Can use to acquire RFPPlayerControl
.
In the case of Video playback, be sure to specify RFPInstreamAdLoaderDelegate.viewControllerForPresentingModalView
.
This is necessary when switching the video to Fullscreen.
For the return value, specify the calling source UIViewController.
func rfpInstreamAdLoaderDidFinishLoadingAd(withReturn instreamAdLoader: RFPInstreamAdLoader!, instreamInfoModels: [Any]!) {
// Acquiring In-Feed advertisement information
for model: RFPInstreamInfoModel in instreamInfoModels as! [RFPInstreamInfoModel] {
if (model.isVideo()) {
// Acquiring RFPPlayerControl
let playerControl = instreamAdLoader.getVideoControl(withFrame: containerView.bounds, infoModel: model)!
// Do not set other than playerUiView
containerView.subviews.forEach { subview in
subview.removeFromSuperview()
}
containerView.addSubview(playerControl)
}
}
}
// ※ Mandatory in case of video advertisement playback
func viewControllerForPresentingModalView() -> UIViewController! {
return self
}
When playback preparation is complete, RFPInstreamAdLoaderDelegate.readyToPlay(with:)
is called.
The initial state of the player is a paused state.
func readyToPlay(with playerControl: RFPPlayerControl!) {
// Playback
playerControl.play()
// Pause
playerControl.pause()
}
Start playback using RFPPlayerControl.play()
.
It is possible to pause using RFPPlayerControl.pause()
.
// Playback
playerControl.play()
// Pause
playerControl.pause()
(Can be used on v2.7.0 or later)
When playback is ended,RFPInstreamAdLoaderDelegate.didPlayToEndTime(with:)
is called.
func didPlayToEndTime(with playerControl: RFPPlayerControl!) {
// for playback ended
}
(Can be used on v2.5.0 or later, iOS11 or later)
In the RFP, video advertisements are cached to a certain extent in the internal storage of the terminal (HLS download storage), and this reduces communication volume and improves the video advertisement playback response.
The setting values recommended by the RFP are used for the cache capacity. This value can be changed from the app side.
When changing the cache capacity, use the RFP.rfpSetVideoCacheSize(_:)
to set the cache capacity.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Acquire current setting value
let size = RFP.rfpGetVideoCacheSize()
//Set the video cache to 100 MB.
RFP.rfpSetVideoCacheSize(100);
// Disable the video cache
RFP.rfpSetVideoCacheSize(0);
// ※ Be sure to set the rfpSetVideoCacheSize before rfpInitMedia
RFP.rfpInitMedia("your_media_id")
}
*In iOS11 or later, the cached video advertisements are displayed with the name”video_ad_cache_rfp
” under ‘[Settings]’>’[General]’>[iPhone storage]
>{each app name}
. This cached file can be deleted at any time by the user.
* The cache is cleared at the time rfpInitMedia
is called. For this reason, the cache capacity temporarily set in rfpSetVideoCacheSize
may be exceeded.
(Can be used on v2.7.0 or later)
Set action when player is tapped.The default is Fullscreen.
RFPPlayerControl.setTapActionFullscreen
RFPPlayerControl.setTapActionAdClick
RFPPlayerControl.replaceTapAction:
// for Fullscreen
playerControl.setTapActionFullscreen()
// for Ad click
playerControl.setTapActionAdClick()
// for arbitrary processing
playerControl.replaceTapAction({ [weak playerControl] () -> Void in
if let weakPlayer = playerControl {
// ex) pause
weakPlayer.pause()
}
})