Windows Dev Center

PlayToSourceRequest.GetDeferral | getDeferral method

Defers connecting a media source to a Play To target.

Syntax


var playToSourceDeferral = playToSourceRequest.getDeferral();

Parameters

This method has no parameters.

Return value

Type: PlayToSourceDeferral

A deferral object that you can use to identify when the deferral is complete.

Remarks

You can use a deferral when you want to make an asynchronous call to retrieve the media element to stream. Play To will then wait for you to supply the media element until you mark the deferral as complete.

To create a deferral, call the GetDeferral method to instruct the PlayToManagerclass to wait to receive a source media element to stream to the Play To target. After you have supplied the source media element to the SetSource method, call the Complete method to end the deferral. If you create a deferral and the wait time exceeds the Deadline property, Play To will continue without a source element from your app.

For an example of how to use Play To in an application, see Quickstart: Using Play To in applications (JavaScript) or Quickstart: Using Play To in applications (C#/VB).

Examples


var ptm = Windows.Media.PlayTo.PlayToManager.getForCurrentView();
ptm.addEventListener("sourcerequested", sourceRequestHandlerDeferred, false);

function sourceRequestHandlerDeferred(e) {
    var deferral = e.sourceRequest.getDeferral();

    // Async call to get source media
    getMediaElementAsync().then(function (element) {
        e.sourceRequest.setSource(element.msPlayToSource);

        deferral.complete();
    });
}


Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Media.PlayTo
Windows::Media::PlayTo [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

Windows.Media.PlayTo
Windows::Media::PlayTo [C++]

Metadata

Windows.winmd

See also

PlayToSourceRequest
Samples
Play To sample
PlayToReceiver sample
Media Server sample

 

 

Show:
© 2015 Microsoft