Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PlayToConnectionErrorEventArgs class

Applies to Windows and Windows Phone

Provides information about the Error event.

Syntax


Public NotInheritable Class PlayToConnectionErrorEventArgs

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

Members

The PlayToConnectionErrorEventArgs class has these types of members:

Methods

The PlayToConnectionErrorEventArgs class inherits methods from the Object class (C#/VB/C++).

Properties

The PlayToConnectionErrorEventArgs class has these properties.

PropertyAccess typeDescription

Code

Read-onlyGets the error code for a Play To connection error.

Message

Read-onlyGets the error message for a Play To connection error.

 

Remarks

In Windows 8 Windows Store app, Code is always set to DeviceError.

In Windows 8.1 Windows Store app, Code is set to either DeviceError or ProtectedPlaybackFailed. This enables the app to determine if the failure is related to the media-protection status of the content. The app can continue playing the next item in the playlist or to stop. Apps can also use this new Code value to remove all protected music from the playlist.

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 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

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

Metadata

Windows.winmd

See also

PlayToConnection.Error event
Samples
Play To sample
PlayToReceiver sample
Media Server sample

 

 

Show:
© 2014 Microsoft