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


/* For information about creating or accessing this object, see Remarks. */

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


var ptm = Windows.Media.PlayTo.PlayToManager.getForCurrentView();
ptm.addEventListener("sourcerequested", sourceRequestHandlerWithEvents, false);
ptm.addEventListener("sourceselected", sourceSelectedHandler, false);

function sourceRequestHandlerWithEvents(e) {
    try {
        var controller = mediaElement.msPlayToSource;

        controller.connection.addEventListener("error", playToConnectionError, false);
        controller.connection.addEventListener("stateChanged", playToConnectionStageChanged, false);
        controller.connection.addEventListener("transferred", playToConnectionTransferred, false);

        e.sourceRequest.setSource(controller);

    } catch (ex) {
        id("messageDiv").innerHTML += "Exception encountered: " + ex.message + "<br/>";
    }
}

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

function sourceSelectedHandler(e) {
    if (mediaElement.id == "iplayer") {
        if (!e.supportsImage) {
            id("messageDiv").innerHTML += e.friendlyName + " does not support streaming images. " +
                                          "Please select a different device.";
            return;
        }
    }

    if (mediaElement.id == "vplayer") {
        if (!e.supportsVideo) {
            id("messageDiv").innerHTML += e.friendlyName + " does not support streaming video. " +
                                          "Please select a different device.";
            return;
        }
    }

    if (mediaElement.id == "aplayer") {
        if (!e.supportsAudio) {
            id("messageDiv").innerHTML += e.friendlyName + " does not support streaming audio. " +
                                          "Please select a different device.";
            return;
        }
    }


    var iconBlob = window.msWWA.createBlobFromRandomAccessStream(e.icon.contentType, e.icon);
    id("playToDeviceIconImage").src = window.URL.createObjectURL(iconBlob, false);

    id("playToDeviceFriendlyName").innerHTML = e.friendlyName;

    id("playToStatusDiv").style.display = "block";
}

function playToConnectionError(e) {
    if (e.code == Windows.Media.PlayTo.PlayToConnectionError.deviceError |
        e.code == Windows.Media.PlayTo.PlayToConnectionError.deviceNotResponding) {

        id("messageDiv").innerHTML += "Error occurred. Disconnecting.<br/>";
    }

    id("messageDiv").innerHTML += "Error: Message = " + e.message.toString() + "<br/>";
}

function playToConnectionStageChanged(e) {
    id("messageDiv").innerHTML += "StateChanged: PreviousState = " + stateToString(e.previousState) + "<br/>";
    id("messageDiv").innerHTML += "StateChanged: CurrentState = " + stateToString(e.currentState) + "<br/>";
}

function stateToString(state) {
    switch (state) {
        case Windows.Media.PlayTo.PlayToConnectionState.connected:
            return "Connected";
        case Windows.Media.PlayTo.PlayToConnectionState.disconnected:
            return "Disconnected";
        case Windows.Media.PlayTo.PlayToConnectionState.rendering:
            return "Rendering";
    }
}

function playToConnectionTransferred(e) {
    id("messageDiv").innerHTML += "Transferred: PreviousSource = " + e.previousSource.toString() + "<br/>";
    id("messageDiv").innerHTML += "Transferred: CurrentSource = " + e.currentSource.toString() + "<br/>";
}



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. All rights reserved.