new VastAdUnit(vastChain, videoAdContainer, optionsopt)
This class provides everything necessary to run a Vast 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
error
If an error occurs it will contain the reference to the error otherwise it will be bull
- Overrides:
- Source:
errorCode
If an error occurs it will contain the Vast Error code of the error
- Overrides:
- Source:
icons
- Inherited From:
- Source:
type
Ad unit type. Will be VAST
for VastAdUnit
- 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
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.
- Overrides:
- Source:
duration() → {number}
Returns the duration of the ad Creative or 0 if there is no creative.
- Overrides:
- 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:
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:
(async) resize(width, height, viewmode) → {Promise}
This method resizes the ad unit to fit the available space in the passed VideoAdContainer
Parameters:
Name | Type | Description |
---|---|---|
width |
number |
the new width of the ad container. |
height |
number |
the new height of the ad container. |
viewmode |
string |
fullscreen | normal | thumbnail |
- Overrides:
- Source:
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: