PlayToSourceDeferral PlayToSourceDeferral PlayToSourceDeferral PlayToSourceDeferral PlayToSourceDeferral Class


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

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


private Windows.Media.PlayTo.PlayToManager ptm = 

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();

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) {

Private ptm As Windows.Media.PlayTo.PlayToManager =

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()

End Sub


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.


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

Ends the deferral.

See Also