There are two approaches to invoke a video in the application.
1. Call invokeApplixirVideoUnit in the onClick handler of an object which you want to associate with the video. This will load the video and start playing it. For example,
<script>
var options = {
zoneId: 2050, //Zone Id
};
invokeApplixirVideoUnit(options); // Invoke Video ad
</script>
2. In the second approach, you can use a Preload API to load the ad into memory before it is played. Once the ad is initiated, it can be played as required. This approach helps display the ad faster when Media Player loads.
Initialize method initApplixirVideoUnit can be invoked any time after the application has been initialized. After initialization, play the ad using playApplixirVideoUnit method. For example,
<script type=’application/javascript’>
var options = {
zoneId: 1234,
adStatusCb: adStatusCallback
};
showRewardAdButton.hidden = true;
initApplixirVideoUnit(options); //initialize the video before loading
function adStatusCallback(status) {
console.log('Ad Status: ' + status);
if (status === "ad-initready") {
showRewardAdButton.hidden = false;
}
}
showRewardAdButton.onClick = function () {
playApplixirVideoUnit(options); //play the video ad
};
</script>
Note:
- Always call the method invokeApplixirVideoUnit and playApplixirVideoUnit from within an onClick handler. This ensures that the ads are shown as per the user permission rules for videos, enforced by all the browsers else the ads will be blocked.
- initApplixirVideoUnit can be called any time after the app has been initialized.
- Any subsequent calls to initApplixirVideoUnit or invokeApplixirVideoUnit should occur no sooner than 1-3 mins after ‘sys-closing’ status callback has been received. If you are using Reward Management system, then it should occur no sooner than the setting you chose for the setting “time between callbacks”.