Represents a Play To target.
The PlayToReceiver class has these types of members:
The PlayToReceiver class has these constructors.
|PlayToReceiver||Creates a new instance of a Play To receiver.|
The PlayToReceiver class has these events.
|CurrentTimeChangeRequested||Occurs when the time location of the playback has changed.|
|MuteChangeRequested||Occurs when the audio has been muted or unmuted.|
|PauseRequested||Occurs when audio or video playback has been paused.|
|PlaybackRateChangeRequested||Occurs when the rate of audio or video playback has changed.|
|PlayRequested||Occurs when audio or video playback starts.|
|SourceChangeRequested||Occurs when the source media for the Play To receiver have changed.|
|StopRequested||Occurs when a request has been made for the Play To receiver to stop playing the streamed media.|
|TimeUpdateRequested||Occurs when the current playback position has changed.|
|VolumeChangeRequested||Occurs when the volume for the source audio or video has changed.|
The PlayToReceiver class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
|NotifyDurationChange||Notifies the Play To receiver that the duration of the audio or video playback has changed.|
|NotifyEnded||Notifies the Play To receiver that the audio or video playback has ended.|
|NotifyError||Notifies the Play To receiver that an error has occurred in displaying or playing the media.|
|NotifyLoadedMetadata||Notifies the Play To receiver that metadata for the media has finished loading.|
|NotifyPaused||Notifies the Play To receiver that the audio or video playback has been paused.|
|NotifyPlaying||Notifies the Play To receiver that the audio or video playback has started.|
|NotifyRateChange||Notifies the Play To receiver that the rate of the audio or video playback has changed.|
|NotifySeeked||Notifies the Play To receiver that the audio or video playback element has started at a new playback location.|
|NotifySeeking||Notifies the Play To receiver that the audio or video playback element is seeking a new playback location.|
|NotifyStopped||Notifies the Play To receiver that the audio or video playback has stopped.|
|NotifyTimeUpdate||Notifies the Play To receiver that the time location of the audio or video playback has changed.|
|NotifyVolumeChange||Notifies the Play To receiver that the volume of the audio or video playback has changed.|
|StartAsync||Start receiving Play To commands.|
|StopAsync||Stop receiving Play To commands.|
The PlayToReceiver class has these properties.
|Read/write||Gets or sets the display name of the Play To target.|
|Read-only||Gets a set of custom properties for the Play To receiver.|
|Read/write||Gets or sets a value that indicates whether the Play To target supports audio.|
|Read/write||Gets or sets a value that indicates whether the Play To target supports images.|
|Read/write||Gets or sets a value that indicates whether the Play To target supports video.|
You can use the PlayToReceiver class to create a custom software Play To receiver that is a digital media renderer for computers on your network. You can include a PlayToReceiver object in your app to handle communication with Play To client computers, and then play or display content streamed from those computers using your own media elements or controls.
The members of the PlayToReceiver class consist of the following:
- The FriendlyName property that identifies the name of the Play To receiver when it is advertised on the network.
- Properties that identify the type of media that your Play To receiver supports: SupportsAudio, SupportsVideo, SupportsImage.
- The StartAsync method that starts the Play To receiver and advertises it on the network as a digital media renderer. The StopAsync method that stops the Play To receiver and stops advertising it on the network.
- The SourceChangeRequested event that occurs when you receive a media stream from a computer, and events that occur when an action is requested by the Play To client computer such as a volume change, or a change in the playback location of the streamed media: CurrentTimeChangeRequested, MuteChangeRequested, PauseRequested, PlayRequested, StopRequested, VolumeChangeRequested, TimeUpdateRequested.
- Methods that you can call to notify the Play To client when a change occurs for your Play To receiver: NotifyDurationChange, NotifyEnded, NotifyError, NotifyLoadedMetadata, NotifyPaused, NotifyPlaying, NotifyRateChange, NotifySeeked, NotifySeeking, NotifyStopped, NotifyTimeUpdate, NotifyVolumeChange.
In Play To, video starts from the current position. If you want to start the video from the beginning, simply seek to the beginning of the video as soon as the Play To connection is established.
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
PlayTo apps will not be suspended as long as video or music is playing on the Play To receiver or images are continuously sent to the Play To receiver. Apps have approximately 10 seconds to send a new image after the current one is displayed and approximately 10 seconds to send the next audio or video after the current one has ended.
Note : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
Minimum supported client
|Windows 8 [Windows Store apps only]|
Minimum supported server
|Windows Server 2012 [Windows Store apps only]|
Minimum supported phone