PlayToSourceDeferral PlayToSourceDeferral PlayToSourceDeferral PlayToSourceDeferral Class

Definition

Represents a deferred operation when you're supplying a source media element for Play To.

public : sealed class PlayToSourceDeferral : IPlayToSourceDeferral
public sealed class PlayToSourceDeferral : IPlayToSourceDeferral
Public NotInheritable Class PlayToSourceDeferral Implements IPlayToSourceDeferral
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

private Windows.Media.PlayTo.PlayToManager ptm = 
        Windows.Media.PlayTo.PlayToManager.GetForCurrentView();

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    ptm.SourceRequested += sourceRequestHandlerDeferred;
}

async private void sourceRequestHandlerDeferred(
    Windows.Media.PlayTo.PlayToManager sender,
    Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e) 
{
    var deferral = e.SourceRequest.GetDeferral();

    // Async call to get source media
    var element = await getMediaElementAsync();
    e.SourceRequest.SetSource(element.PlayToSource);

    deferral.Complete();
}
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();
    });
}
Private ptm As Windows.Media.PlayTo.PlayToManager =
    Windows.Media.PlayTo.PlayToManager.GetForCurrentView()

Protected Overrides Sub OnNavigatedTo(e As Navigation.NavigationEventArgs)
    AddHandler ptm.SourceRequested, AddressOf sourceRequestHandlerDeferred
End Sub

Private Async Sub sourceRequestHandlerDeferred(
    sender As Windows.Media.PlayTo.PlayToManager,
    e As Windows.Media.PlayTo.PlayToSourceRequestedEventArgs)

    Dim deferral = e.SourceRequest.GetDeferral()

    ' Async call to get source media
    Dim element = Await getMediaElementAsync()
    e.SourceRequest.SetSource(element.PlayToSource)

    deferral.Complete()
End Sub

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 PlayToManager class to wait to receive a source media element to stream to the Play To target. After you've 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 PlayReady DRM.

Methods

Complete() Complete() Complete() Complete()

Ends the deferral.

public : void Complete()
public void Complete()
Public Function Complete() As void
playToSourceDeferral.complete();
See Also

See Also