Windows Dev Center

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.

PlayToConnectionError enumeration

Describes an error on a Play To connection.

Syntax


var value = Windows.Media.PlayTo.PlayToConnectionError.none;

Attributes

[Version(0x06020000)]

Members

The PlayToConnectionError enumeration has these members.

MemberValueDescription
None | none0

No error occurred.

DeviceNotResponding | deviceNotResponding1

The Play To target device has not responded for at least 5 seconds.

DeviceError | deviceError2

The Play To target device has encountered an error.

DeviceLocked | deviceLocked3

The Play To target device is locked.

ProtectedPlaybackFailed | protectedPlaybackFailed4

The Play To target device failed to play the protected content.

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


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 (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

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

PlayToConnectionErrorEventArgs.Code Property
PlayToConnection.Error Event
Samples
Play To sample
PlayToReceiver sample
Media Server sample

 

 

Show:
© 2015 Microsoft