PlayToConnectionStateChangedEventArgs.CurrentState | currentState property

Applies to Windows and Windows Phone

Gets the current state after the Play To connection state has changed.

Syntax


Public ReadOnly Property CurrentState As PlayToConnectionState

Property value

Type: PlayToConnectionState

The current state after the Play To connection state has changed.

Remarks

For an example of how to use Play To in an application, see Quickstart: Using Play To in applications (JavaScript) or Quickstart: Using Play To in applications (C#/VB).

Examples


    Private ptm As Windows.Media.PlayTo.PlayToManager =
            Windows.Media.PlayTo.PlayToManager.GetForCurrentView()

    Protected Overrides Sub OnNavigatedTo(e As Navigation.NavigationEventArgs)
        AddHandler ptm.SourceRequested, AddressOf sourceRequestHandlerWithEvents
        AddHandler ptm.SourceSelected, AddressOf sourceSelectedHandler
    End Sub

    Private Sub sourceRequestHandlerWithEvents(
        sender As Windows.Media.PlayTo.PlayToManager,
        e As Windows.Media.PlayTo.PlayToSourceRequestedEventArgs)

        Try
            Dim controller = mediaElement.PlayToSource

            AddHandler controller.Connection.Error, AddressOf playToConnectionError
            AddHandler controller.Connection.StateChanged, AddressOf playToConnectionStageChanged
            AddHandler controller.Connection.Transferred, AddressOf playToConnectionTransferred

            e.SourceRequest.SetSource(controller)
        Catch ex As Exception
            messageBlock.Text &= "Exception encountered: " & ex.Message & vbCrLf
        End Try
    End Sub

    ' Called when the user selects a Play To device to stream to.

    Private Sub sourceSelectedHandler(
        sender As Windows.Media.PlayTo.PlayToManager,
        e As Windows.Media.PlayTo.PlayToSourceSelectedEventArgs)

        If mediaElement.Name = "iplayer" Then
            If Not e.SupportsImage Then
                messageBlock.Text &= e.FriendlyName & " does not support streaming images. " &
                                     "Please select a different device."
                Return
            End If
        End If

        If mediaElement.Name = "vplayer" Then
            If Not e.SupportsVideo Then
                messageBlock.Text &= e.FriendlyName & " does not support streaming video. " &
                                     "Please select a different device."
                Return
            End If
        End If

        If mediaElement.Name = "aplayer" Then
            If Not e.SupportsAudio Then
                messageBlock.Text &= e.FriendlyName & " does not support streaming audio. " &
                                     "Please select a different device."
                Return
            End If
        End If

        Dim iconStream = e.Icon
        Dim iconBitmap = New Windows.UI.Xaml.Media.Imaging.BitmapImage()
        iconBitmap.SetSource(iconStream)
        playToDeviceIconImage.Source = iconBitmap

        playToDeviceFriendlyNameBlock.Text = e.FriendlyName
    End Sub

    Private Sub playToConnectionError(
        connection As Windows.Media.PlayTo.PlayToConnection,
        e As Windows.Media.PlayTo.PlayToConnectionErrorEventArgs)

        If e.Code = Windows.Media.PlayTo.PlayToConnectionError.DeviceError OrElse
            e.Code = Windows.Media.PlayTo.PlayToConnectionError.DeviceNotResponding Then

            messageBlock.Text &= "Error occurred. Disconnecting." & vbCrLf
        End If

        messageBlock.Text &= "Error: Message = " & e.Message.ToString() & vbCrLf
    End Sub

    Private Sub playToConnectionStageChanged(
        connection As Windows.Media.PlayTo.PlayToConnection,
        e As Windows.Media.PlayTo.PlayToConnectionStateChangedEventArgs)

        messageBlock.Text &= "StateChanged: PreviousState = " & e.PreviousState.ToString() & vbCrLf
        messageBlock.Text &= "StateChanged: CurrentState = " & e.CurrentState.ToString() & vbCrLf
    End Sub

    Private Sub playToConnectionTransferred(
        connection As Windows.Media.PlayTo.PlayToConnection,
        e As Windows.Media.PlayTo.PlayToConnectionTransferredEventArgs)

        messageBlock.Text &= "Transferred: PreviousSource = " & e.PreviousSource.ToString() & vbCrLf
        messageBlock.Text &= "Transferred: CurrentSource = " & e.CurrentSource.ToString() & vbCrLf
    End Sub


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Media.PlayTo
Windows::Media::PlayTo [C++]

Metadata

Windows.winmd

See also

PlayToConnectionStateChangedEventArgs
Samples
Play To sample
PlayToReceiver sample
Media Server sample

 

 

Show:
© 2014 Microsoft