PlayToConnectionTransferredEventArgs class

Applies to Windows and Windows Phone

Provides information about the Transferred event.

Syntax


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

Attributes

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

Members

The PlayToConnectionTransferredEventArgs class has these types of members:

Methods

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

Properties

The PlayToConnectionTransferredEventArgs class has these properties.

PropertyAccess typeDescription

CurrentSource

Read-onlyGets the current Play To source that a connection was transferred to.

PreviousSource

Read-onlyGets the previous Play To source that a connection was transferred from.

 

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

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

Samples
Play To sample
PlayToReceiver sample
Media Server sample

 

 

Show:
© 2014 Microsoft