共用方式為


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 方法結束延遲。 如果您建立延遲且等候時間超過 [期限 ] 屬性,Play To 將會繼續,而不會有來自您 app 的來源元素。

如需如何在應用程式中使用 Play To 的範例,請參閱 PlayReady DRM

適用於

另請參閱