Compartir a través de


PlayToReceiver Clase

Definición

Representa un destino De reproducción.

public ref class PlayToReceiver sealed
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class PlayToReceiver final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class PlayToReceiver final
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class PlayToReceiver
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class PlayToReceiver
function PlayToReceiver()
Public NotInheritable Class PlayToReceiver
Herencia
Object Platform::Object IInspectable PlayToReceiver
Atributos

Requisitos de Windows

Familia de dispositivos
Windows 10 (se introdujo en la versión 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (se introdujo en la versión v1.0)
Características de aplicaciones
privateNetworkClientServer

Comentarios

Puede usar la clase PlayToReceiver para crear un receptor Play To de software personalizado que sea un representador multimedia digital para equipos de la red. Puedes incluir un objeto PlayToReceiver en la aplicación para controlar la comunicación con los equipos cliente de Play To y, a continuación, reproducir o mostrar contenido transmitido desde esos equipos con tus propios controles o elementos multimedia.

Los miembros de la clase PlayToReceiver constan de lo siguiente:

En Reproducir a, el vídeo comienza desde la posición actual. Si desea iniciar el vídeo desde el principio, simplemente busque el principio del vídeo en cuanto se establezca la conexión Reproducir a.

Para obtener un ejemplo de cómo crear un receptor de reproducción de software, consulte Conversión multimedia.

Windows.Media.PlayTo.PlayToReceiver receiver;
Windows.System.Display.DisplayRequest display;
Windows.UI.Core.CoreDispatcher dispatcher;
bool seeking = false;

private async void StartReceiverButton_Click(object sender, RoutedEventArgs e)
{
    try
    {
        dispatcher = Window.Current.CoreWindow.Dispatcher;

        if (receiver == null)
        {
            receiver = new Windows.Media.PlayTo.PlayToReceiver();
        }

        // Add Play To Receiver events and properties
        receiver.CurrentTimeChangeRequested += receiver_CurrentTimeChangeRequested;
        receiver.MuteChangeRequested += receiver_MuteChangeRequested;
        receiver.PauseRequested += receiver_PauseRequested;
        receiver.PlaybackRateChangeRequested += receiver_PlaybackRateChangeRequested;
        receiver.PlayRequested += receiver_PlayRequested;
        receiver.SourceChangeRequested += receiver_SourceChangeRequested;
        receiver.StopRequested += receiver_StopRequested;
        receiver.TimeUpdateRequested += receiver_TimeUpdateRequested;
        receiver.VolumeChangeRequested += receiver_VolumeChangeRequested;

        receiver.FriendlyName = "Sample Play To Receiver";
        receiver.SupportsAudio = false;
        receiver.SupportsVideo = true;
        receiver.SupportsImage = false;

        // Add MediaElement events
        VideoPlayer.CurrentStateChanged += VideoPlayer_CurrentStateChanged;
        VideoPlayer.MediaEnded += VideoPlayer_MediaEnded;
        VideoPlayer.MediaFailed += VideoPlayer_MediaFailed;
        VideoPlayer.MediaOpened += VideoPlayer_MediaOpened;
        VideoPlayer.RateChanged += VideoPlayer_RateChanged;
        VideoPlayer.SeekCompleted += VideoPlayer_SeekCompleted;
        VideoPlayer.VolumeChanged += VideoPlayer_VolumeChanged;

        // Advertise the receiver on the local network and start receiving commands
        await receiver.StartAsync();

        // Prevent the screen from locking
        if (display == null)
            display = new Windows.System.Display.DisplayRequest();
        display.RequestActive();

        StatusTextBlock.Text = "'" + receiver.FriendlyName + "' started.";
    }
    catch
    {
        receiver = null;
        StatusTextBlock.Text = "Failed to start receiver.";
    }
}

private async void StopReceiverButton_Click(object sender, RoutedEventArgs e)
{
    try
    {
        if (receiver != null)
        {
            await receiver.StopAsync();

            if (display != null)
                display.RequestRelease();

            // Remove Play To Receiver events
            receiver.CurrentTimeChangeRequested -= receiver_CurrentTimeChangeRequested;
            receiver.MuteChangeRequested -= receiver_MuteChangeRequested;
            receiver.PauseRequested -= receiver_PauseRequested;
            receiver.PlaybackRateChangeRequested -= receiver_PlaybackRateChangeRequested;
            receiver.PlayRequested -= receiver_PlayRequested;
            receiver.SourceChangeRequested -= receiver_SourceChangeRequested;
            receiver.StopRequested -= receiver_StopRequested;
            receiver.TimeUpdateRequested -= receiver_TimeUpdateRequested;
            receiver.VolumeChangeRequested -= receiver_VolumeChangeRequested;

            //  Remove MediaElement events
            VideoPlayer.Pause();

            VideoPlayer.CurrentStateChanged -= VideoPlayer_CurrentStateChanged;
            VideoPlayer.MediaEnded -= VideoPlayer_MediaEnded;
            VideoPlayer.MediaFailed -= VideoPlayer_MediaFailed;
            VideoPlayer.MediaOpened -= VideoPlayer_MediaOpened;
            VideoPlayer.RateChanged -= VideoPlayer_RateChanged;
            VideoPlayer.SeekCompleted -= VideoPlayer_SeekCompleted;
            VideoPlayer.VolumeChanged -= VideoPlayer_VolumeChanged;

            StatusTextBlock.Text = "Stopped '" + receiver.FriendlyName + "'.";
        }
    }
    catch
    {
        StatusTextBlock.Text = "Failed to stop '" + receiver.FriendlyName + "'.";
    }
}
Private receiver As Windows.Media.PlayTo.PlayToReceiver
Private display As Windows.System.Display.DisplayRequest
Private seeking As Boolean = False

Private Async Sub StartReceiverButton_Click()
    Try
        If receiver Is Nothing Then
            receiver = New Windows.Media.PlayTo.PlayToReceiver()
        End If

        ' Add Play To Receiver events and properties
        AddHandler receiver.CurrentTimeChangeRequested, AddressOf receiver_CurrentTimeChangeRequested
        AddHandler receiver.MuteChangeRequested, AddressOf receiver_MuteChangeRequested
        AddHandler receiver.PauseRequested, AddressOf receiver_PauseRequested
        AddHandler receiver.PlaybackRateChangeRequested, AddressOf receiver_PlaybackRateChangeRequested
        AddHandler receiver.PlayRequested, AddressOf receiver_PlayRequested
        AddHandler receiver.SourceChangeRequested, AddressOf receiver_SourceChangeRequested
        AddHandler receiver.StopRequested, AddressOf receiver_StopRequested
        AddHandler receiver.TimeUpdateRequested, AddressOf receiver_TimeUpdateRequested
        AddHandler receiver.VolumeChangeRequested, AddressOf receiver_VolumeChangeRequested

        receiver.FriendlyName = "Sample Play To Receiver"
        receiver.SupportsAudio = False
        receiver.SupportsVideo = True
        receiver.SupportsImage = False

        ' Add MediaElement events
        AddHandler VideoPlayer.CurrentStateChanged, AddressOf VideoPlayer_CurrentStateChanged
        AddHandler VideoPlayer.MediaEnded, AddressOf VideoPlayer_MediaEnded
        AddHandler VideoPlayer.MediaFailed, AddressOf VideoPlayer_MediaFailed
        AddHandler VideoPlayer.MediaOpened, AddressOf VideoPlayer_MediaOpened
        AddHandler VideoPlayer.RateChanged, AddressOf VideoPlayer_RateChanged
        AddHandler VideoPlayer.SeekCompleted, AddressOf VideoPlayer_SeekCompleted
        AddHandler VideoPlayer.VolumeChanged, AddressOf VideoPlayer_VolumeChanged

        ' Advertise the receiver on the local network and start receiving commands
        Await receiver.StartAsync()

        ' Prevent the screen from locking
        If display Is Nothing Then
            display = New Windows.System.Display.DisplayRequest()
            display.RequestActive()

            StatusTextBlock.Text = "'" & receiver.FriendlyName & "' started."
        End If
    Catch
        receiver = Nothing
        StatusTextBlock.Text = "Failed to start receiver. "
    End Try
End Sub

Private Async Sub StopReceiverButton_Click()
    Try
        If receiver IsNot Nothing Then
            Await receiver.StopAsync()

            If display IsNot Nothing Then display.RequestRelease()

            ' Remove Play To Receiver events
            RemoveHandler receiver.CurrentTimeChangeRequested, AddressOf receiver_CurrentTimeChangeRequested
            RemoveHandler receiver.MuteChangeRequested, AddressOf receiver_MuteChangeRequested
            RemoveHandler receiver.PauseRequested, AddressOf receiver_PauseRequested
            RemoveHandler receiver.PlaybackRateChangeRequested, AddressOf receiver_PlaybackRateChangeRequested
            RemoveHandler receiver.PlayRequested, AddressOf receiver_PlayRequested
            RemoveHandler receiver.SourceChangeRequested, AddressOf receiver_SourceChangeRequested
            RemoveHandler receiver.StopRequested, AddressOf receiver_StopRequested
            RemoveHandler receiver.TimeUpdateRequested, AddressOf receiver_TimeUpdateRequested
            RemoveHandler receiver.VolumeChangeRequested, AddressOf receiver_VolumeChangeRequested

            '  Remove MediaElement events
            VideoPlayer.Pause()

            RemoveHandler VideoPlayer.CurrentStateChanged, AddressOf VideoPlayer_CurrentStateChanged
            RemoveHandler VideoPlayer.MediaEnded, AddressOf VideoPlayer_MediaEnded
            RemoveHandler VideoPlayer.MediaFailed, AddressOf VideoPlayer_MediaFailed
            RemoveHandler VideoPlayer.MediaOpened, AddressOf VideoPlayer_MediaOpened
            RemoveHandler VideoPlayer.RateChanged, AddressOf VideoPlayer_RateChanged
            RemoveHandler VideoPlayer.SeekCompleted, AddressOf VideoPlayer_SeekCompleted
            RemoveHandler VideoPlayer.VolumeChanged, AddressOf VideoPlayer_VolumeChanged

            StatusTextBlock.Text = "Stopped '" & receiver.FriendlyName & "'."
        End If
    Catch
        StatusTextBlock.Text = "Failed to stop '" & receiver.FriendlyName & "'."
    End Try
End Sub

Las aplicaciones PlayTo no se suspenderán siempre que el vídeo o la música se reproduzca en el receptor Play To o las imágenes se envíen continuamente al receptor Reproducir a. Las aplicaciones tienen aproximadamente 10 segundos para enviar una nueva imagen después de que se muestre la actual y aproximadamente 10 segundos para enviar el siguiente audio o vídeo después de que haya finalizado el actual.

Nota

Esta clase no es ágil, lo que significa que debe tener en cuenta su modelo de subprocesos y el comportamiento de serialización. Para obtener más información, vea Subprocesos y serialización (C++/CX) y Uso de objetos Windows Runtime en un entorno multiproceso (.NET).

Constructores

PlayToReceiver()

Crea una nueva instancia de un receptor Play To.

Propiedades

FriendlyName

Obtiene o establece el nombre para mostrar del destino Play To.

Properties

Obtiene un conjunto de propiedades personalizadas para el receptor Reproducir a.

SupportsAudio

Obtiene o establece un valor que indica si el destino Reproducir para admite audio.

SupportsImage

Obtiene o establece un valor que indica si el destino Reproducir para admite imágenes.

SupportsVideo

Obtiene o establece un valor que indica si el destino Reproducir para admite vídeo.

Métodos

NotifyDurationChange(TimeSpan)

Notifica al receptor Reproducir a que ha cambiado la duración de la reproducción de audio o vídeo.

NotifyEnded()

Notifica al receptor Reproducir a que ha finalizado la reproducción de audio o vídeo.

NotifyError()

Notifica al receptor Reproducir a que se ha producido un error al mostrar o reproducir el medio.

NotifyLoadedMetadata()

Notifica al receptor Reproducir a que los metadatos del medio han terminado de cargarse.

NotifyPaused()

Notifica al receptor Reproducir a que se ha pausado la reproducción de audio o vídeo.

NotifyPlaying()

Notifica al receptor Reproducir a que se ha iniciado la reproducción de audio o vídeo.

NotifyRateChange(Double)

Notifica al receptor Reproducir a que ha cambiado la velocidad de reproducción de audio o vídeo.

NotifySeeked()

Notifica al receptor Reproducir a que el elemento de reproducción de audio o vídeo se ha iniciado en una nueva ubicación de reproducción.

NotifySeeking()

Notifica al receptor Reproducir a que el elemento de reproducción de audio o vídeo está buscando una nueva ubicación de reproducción.

NotifyStopped()

Notifica al receptor Reproducir a que se ha detenido la reproducción de audio o vídeo.

NotifyTimeUpdate(TimeSpan)

Notifica al receptor Reproducir a que la ubicación horaria de la reproducción de audio o vídeo ha cambiado.

NotifyVolumeChange(Double, Boolean)

Notifica al receptor Reproducir a que el volumen de la reproducción de audio o vídeo ha cambiado.

StartAsync()

Empiece a recibir comandos Play To.

StopAsync()

Deje de recibir comandos Play To.

Eventos

CurrentTimeChangeRequested

Se produce cuando ha cambiado la ubicación horaria de la reproducción.

MuteChangeRequested

Se produce cuando el audio se ha silenciado o desactivado.

PauseRequested

Se produce cuando se ha pausado la reproducción de audio o vídeo.

PlaybackRateChangeRequested

Se produce cuando ha cambiado la velocidad de reproducción de audio o vídeo.

PlayRequested

Se produce cuando se inicia la reproducción de audio o vídeo.

SourceChangeRequested

Se produce cuando el medio de origen del receptor Reproducir a ha cambiado.

StopRequested

Se produce cuando se ha realizado una solicitud para que el receptor Reproducir a deje de reproducir el medio transmitido.

TimeUpdateRequested

Se produce cuando ha cambiado la posición de reproducción actual.

VolumeChangeRequested

Se produce cuando el volumen del audio o vídeo de origen ha cambiado.

Se aplica a

Consulte también