共用方式為


PlayToSourceDeferral 類別

定義

當您提供播放至的來源媒體元素時,表示延後作業。

public ref class PlayToSourceDeferral sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Deprecated("PlayToSourceDeferral may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PlayToSourceDeferral final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Deprecated("PlayToSourceDeferral may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Foundation.UniversalApiContract")]
class PlayToSourceDeferral final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Deprecated("PlayToSourceDeferral may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class PlayToSourceDeferral
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Deprecated("PlayToSourceDeferral may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class PlayToSourceDeferral
Public NotInheritable Class PlayToSourceDeferral
繼承
Object Platform::Object IInspectable PlayToSourceDeferral
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

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

備註

當您想要進行異步呼叫以擷取要串流的媒體元素時,可以使用延遲。 Play To 接著會等候您提供媒體元素,直到您將延遲標示為完成為止。

若要建立延遲,請呼叫 GetDeferral 方法,指示 PlayToManager 類別等候接收來源媒體元素以串流至 Play To 目標。 將來源媒體元素提供給 SetSource 方法之後,請呼叫 Complete 方法以結束延遲。 如果您建立延遲,且等候時間超過 [期限 ] 屬性,則 [播放至] 會繼續,而不會有來自您 app 的來源元素。

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

方法

Complete()

結束延遲。

適用於

另請參閱