You can use the requestAd method in the Advertising Module of the Player API to dynamically make an ad request, overriding the ad request policy set for the player in the Advertising module. You can request a mid-roll ad by calling requestAd at any time during media playback. The Player API Reference for the requestAd method includes examples of how to use this method for mid-roll or for simulated pre-roll or post-roll ads.
The requestAd method has the following signature:
public function requestAd(pCuePointKVP:String):void.
The string argument enables passing additional key/value pairs with the ad request. When you call requestAd, the ad request includes the following key/value pairs:
To use the requestAd method, make sure that your player is configured to enable the APIs.
Another way to get an ad to display dynamically is to use the showAd method. You can read more about showAd in Using External Ad Calls.