PlayToConnectionStateChangedEventArgs class
Provides information about the StateChanged event.
Syntax
/* For information about creating or accessing this object, see Remarks. */
Attributes
- MarshalingBehaviorAttribute(Agile)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
Members
The PlayToConnectionStateChangedEventArgs class has these types of members:
Methods
The PlayToConnectionStateChangedEventArgs class inherits methods from the Object class (C#/VB/C++).
Properties
The PlayToConnectionStateChangedEventArgs class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets the current state after the Play To connection state has changed. | |
| Read-only | Gets the previous state before the Play To connection state was 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
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] |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 12/4/2012
