共用方式為


PlayToManager 類別

定義

提供播放至功能的存取權。

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

Windows 需求

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

範例

// 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

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

備註

如果您的應用程式包含音訊、視訊或影像元素,用戶可以將這些元素的媒體來源串流至播放目標裝置。 您可以使用 PlayToManager 類別來自定義使用者的 Play To 體驗。 您可以使用 DefaultSourceSelection 屬性來停用預設行為。您可以使用 SourceRequested 事件來選取要串流的媒體。 而且您可以使用 ShowPlayToUI 方法,顯示播放到 UI 來取代裝置常用鍵。

在 [播放到] 中,影片會從目前的位置開始。 如果您想要從頭開始影片,只要建立 [播放到] 連線,就立即搜尋影片的開頭。

只要視訊或音樂正在播放至接收者或影像持續傳送給播放收件者,PlayTo 應用程式將不會暫停。 應用程式在顯示目前影像之後大約要傳送 10 秒,大約 10 秒才能在目前影像結束之後傳送下一個音訊或視訊。

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

屬性

DefaultSourceSelection

啟用或停用 [播放至] 的預設來源選取專案。

方法

GetForCurrentView()

取得目前檢視的 Play To 管理員。

ShowPlayToUI()

顯示 [播放至 UI]。

事件

SourceRequested

發生於使用者要求媒體串流至播放目標裝置時。

SourceSelected

發生於已選取 [播放至] 來源專案時。

適用於

另請參閱