PlayToSourceRequest.GetDeferral 方法

定义

延迟将媒体源连接到“播放到”目标。

public:
 virtual PlayToSourceDeferral ^ GetDeferral() = GetDeferral;
/// [Windows.Foundation.Metadata.Deprecated("PlayToSourceRequest may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.Foundation.UniversalApiContract)]
PlayToSourceDeferral GetDeferral();
/// [Windows.Foundation.Metadata.Deprecated("PlayToSourceRequest may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Foundation.UniversalApiContract")]
PlayToSourceDeferral GetDeferral();
[Windows.Foundation.Metadata.Deprecated("PlayToSourceRequest may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.Foundation.UniversalApiContract))]
public PlayToSourceDeferral GetDeferral();
[Windows.Foundation.Metadata.Deprecated("PlayToSourceRequest may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Foundation.UniversalApiContract")]
public PlayToSourceDeferral GetDeferral();
function getDeferral()
Public Function GetDeferral () As PlayToSourceDeferral

返回

一个延迟对象,可用于标识延迟何时完成。

属性

示例

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

注解

如果要进行异步调用以检索要流的媒体元素,则可以使用延迟。 然后,“播放到”将等待你提供媒体元素,直到将延迟标记为完成。

若要创建延迟,请调用 GetDeferral 方法以指示 PlayToManager 类等待接收要流式传输到“播放到”目标的源媒体元素。 将源媒体元素提供给 SetSource 方法后,调用 Complete 方法以结束延迟。 如果创建延迟,并且等待时间超过 Deadline 属性,则“播放到”将继续,而无需应用中的源元素。

有关如何在应用程序中使用“播放到”的示例,请参阅 PlayReady DRM

适用于

另请参阅