Play​To​Source​Request Play​To​Source​Request Play​To​Source​Request Class

Definition

Represents a request to connect a media element with a Play To target.

public : sealed class PlayToSourceRequest : IPlayToSourceRequestpublic sealed class PlayToSourceRequest : IPlayToSourceRequestPublic NotInheritable Class PlayToSourceRequest Implements IPlayToSourceRequest
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

// Play To Contract

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

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

private void sourceRequestHandler(
    Windows.Media.PlayTo.PlayToManager sender,
    Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
{
    try
    {
        e.SourceRequest.SetSource(mediaElement.PlayToSource);
    }
    catch (Exception ex)
    {
        messageBlock.Text += "Exception encountered: " + ex.Message + "\n";
    }
}
// Play To Contract

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

function sourceRequestHandler(e) {
    try {
        e.sourceRequest.setSource(mediaElement.msPlayToSource);

    } catch (ex) {
        id("messageDiv").innerHTML += "Exception encountered: " + ex.message + "<br/>";
    }
}
' Play To Contract

Private ptm As Windows.Media.PlayTo.PlayToManager =
        Windows.Media.PlayTo.PlayToManager.GetForCurrentView()

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

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

    Try
        e.SourceRequest.SetSource(mediaElement.PlayToSource)
    Catch ex As Exception
        messageBlock.Text &= "Exception encountered: " & ex.Message & vbCrLf
    End Try
End Sub

Remarks

The PlayToSourceRequest class represents a user request for source media to stream to a Play To target. You use the SourceRequest property of the PlayToSourceRequestedEventArgs class to pass media from your application to Play To during the SourceRequested event.

You can use the GetDeferral method to create a deferral for 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.

For an example of how to use Play To in an application, see Quickstart: Using Play To in applications (JavaScript) or PlayReady DRM.

Properties

Deadline Deadline Deadline

Gets the time limit to supply the Play To source element.

public : DateTime Deadline { get; }public DateTimeOffset Deadline { get; }Public ReadOnly Property Deadline As DateTimeOffset
Value
DateTime DateTimeOffset DateTimeOffset

The time limit to supply the Play To source element.

Attributes
See Also

Methods

DisplayErrorString(String) DisplayErrorString(String) DisplayErrorString(String)

Displays an error message in the Play To UI.

public : void DisplayErrorString(PlatForm::String errorString)public void DisplayErrorString(String errorString)Public Function DisplayErrorString(errorString As String) As void
Parameters
errorString
PlatForm::String String String

The error message to display in the Play To UI.

Attributes
See Also

GetDeferral() GetDeferral() GetDeferral()

Defers connecting a media source to a Play To target.

public : PlayToSourceDeferral GetDeferral()public PlayToSourceDeferral GetDeferral()Public Function GetDeferral() As PlayToSourceDeferral
Returns

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

Attributes

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 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 PlayReady DRM.

See Also

SetSource(PlayToSource) SetSource(PlayToSource) SetSource(PlayToSource)

Sets the source element to connect to the Play To target.

public : void SetSource(PlayToSource value)public void SetSource(PlayToSource value)Public Function SetSource(value As PlayToSource) As void
Parameters
value
PlayToSource PlayToSource PlayToSource

The source element to connect to the Play To target.

Attributes

Remarks

The PlayToSourceRequest class represents a user request for source media to stream to a Play To target. You use the SourceRequest property of the PlayToSourceRequestedEventArgs class to pass media from your application to Play To during the SourceRequested event.

See Also

See Also