AdScheduler.requestScheduleByUri method
Requests an ad schedule from the server specified in the URI and insert it into the timeline of the MediaPlayer that was passed to the AdScheduler constructor.
Syntax
var promise = adScheduler.requestScheduleByUri(adServiceUrl);
Parameters
- adServiceUrl [in]
-
Type: String
The URL of the server from which to request an ad schedule instead of the default Microsoft ad server.
Return value
Type: Promise
A Promise object that completes when the schedule has been received.
Remarks
The ad payload that is returned by adServiceUrl must conform to the Video Ad Serving Template (VAST) or Video Multiple Ad Playlist (VMAP) payload formats.
Applications should wait for requestScheduleByUri to return before starting to play the primary video content in the MediaPlayer. Starting to play media before requestScheduleByUri returns (in the case of a pre-roll advertisement) will result in the pre-roll interrupting the primary video content.
Use the then method of the Promise return value to specify the onComplete function to call when the promise completes successfully and the onError function to call if an error is encountered.
- In your onComplete function, start playback of your video content. The ad will start playing at the scheduled time.
- In your onError function, handle the error and then start playback of your video. Your video content will play without an ad. The argument of the onError function is an object that contains the following members.
Member Description errorMessage A string that describes the error. errorCode One of the ErrorCode values.
Requirements
|
Client |
Windows 10 |
|---|---|
|
Namespace |
MicrosoftNSJS.Advertising |
|
Library |
|
See also