new VpaidAdUnit(vastChain, videoAdContainer, optionsopt)
This class provides everything necessary to run a Vpaid ad.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
vastChain |
VastChain |
The VastChain with all the VastResponse |
|||||||||||||||||
videoAdContainer |
VideoAdContainer |
container instance to place the ad |
|||||||||||||||||
options |
Object |
<optional> |
Options Map. The allowed properties are: Properties
|
- Implements:
- Source:
Extends
Members
creativeAd
Reference to the Vpaid Creative ad unit. Will be null before the ad unit starts.
- Source:
error
If an error occurs it will contain the reference to the error otherwise it will be bull
- Inherited From:
- Source:
errorCode
If an error occurs it will contain the Vast Error code of the error
- Inherited From:
- Source:
icons
- Overrides:
- Source:
type
Ad unit type. Will be VPAID
for VpaidAdUnit
- Overrides:
- Source:
vastChain
Reference to the VastChain used to load the ad.
- Inherited From:
- Source:
videoAdContainer
Reference to the VideoAdContainer that contains the ad.
- Inherited From:
- Source:
Methods
(async) cancel()
Cancels the ad unit.
- Overrides:
- Source:
Throws:
if ad unit is finished.
currentTime() → {number}
Returns the current time of the ad Creative or 0 if there is no creative.
Note: if the user has engaged with the ad, the currentTime becomes unknown and it will return 0;
- Overrides:
- Source:
duration() → {number}
Returns the duration of the ad Creative or 0 if there is no creative.
Note: if the user has engaged with the ad, the duration becomes unknown and it will return 0;
- Overrides:
- Source:
emit(eventName) → {boolean}
Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string |
The name of the event. |
- Inherited From:
- Source:
getVolume() → {number}
Gets the volume of the ad unit.
- Overrides:
- Source:
Throws:
-
if ad unit is not started.
-
if ad unit is finished.
isFinished() → {boolean}
- Inherited From:
- Source:
isStarted() → {boolean}
- Inherited From:
- Source:
on(eventName, listener) → {Emitter}
Adds the listener function to the end of the listeners array for the event named eventName.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string |
The name of the event. |
listener |
function |
Listener fn that handles the evt. |
- Inherited From:
- Source:
once(eventName, listener) → {Emitter}
Adds a one time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string |
The name of the event. |
listener |
function |
Listener fn that handles the evt. |
- Inherited From:
- Source:
onError(callback)
Register a callback function that will be called if there is an error while running the ad.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
will be called on ad unit error passing the Error instance and an object with the adUnit and the VastChain. |
- Inherited From:
- Source:
Throws:
if ad unit is finished.
onFinish(callback)
Register a callback function that will be called whenever the ad finishes. No matter if it was finished because de ad ended, or cancelled or there was an error playing the ad.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
will be called once the ad unit finished |
- Inherited From:
- Source:
Throws:
if ad unit is finished.
pause()
Pauses the ad unit.
- Overrides:
- Source:
Throws:
-
if ad unit is not started.
-
if ad unit is finished.
paused()
Returns true if the ad is paused and false otherwise
- Overrides:
- Source:
removeAllListeners(eventName) → {Emitter}
Removes all listeners, or those of the specified eventName.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string |
The name of the event. Optional if omitted all listeners will be removed. |
- Inherited From:
- Source:
removeListener(eventName, listener) → {Emitter}
Removes the specified listener from the listener array for the event named eventName.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string |
The name of the event. |
listener |
function |
Listener fn that handles the evt. |
- Inherited From:
- Source:
(async) resize() → {Promise}
This method resizes the ad unit to fit the available space in the passed VideoAdContainer
- Overrides:
- Source:
Throws:
-
if ad unit is not started.
-
if ad unit is finished.
resume()
Resumes a previously paused ad unit.
- Overrides:
- Source:
Throws:
-
if ad unit is not started.
-
if ad unit is finished.
setVolume(volume)
Sets the volume of the ad unit.
Parameters:
Name | Type | Description |
---|---|---|
volume |
number |
must be a value between 0 and 1; |
- Overrides:
- Source:
Throws:
-
if ad unit is not started.
-
if ad unit is finished.
(async) start()
Starts the ad unit.
- Source:
Throws:
-
if called twice.
-
if ad unit is finished.
Events
adProgress
fires on ad progress.
- Inherited From:
- Source:
finish
Fires when the adUnit's has finished.
- Inherited From:
- Source:
volumeChanged
Fires when the adUnit's volume has changed.
- Inherited From:
- Source: