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


public enum PlayToConnectionError

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 PlayReady DRM.

Examples


    private Windows.Media.PlayTo.PlayToManager ptm = 
    Windows.Media.PlayTo.PlayToManager.GetForCurrentView();

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
ptm.SourceRequested += sourceRequestHandlerWithEvents;
ptm.SourceSelected += sourceSelectedHandler;
    }

    private void sourceRequestHandlerWithEvents(
    Windows.Media.PlayTo.PlayToManager sender,
    Windows.Media.PlayTo.PlayToSourceRequestedEventArgs e)
    {
try
{
    var controller = mediaElement.PlayToSource;

    controller.Connection.Error += playToConnectionError;
    controller.Connection.StateChanged += playToConnectionStageChanged;
    controller.Connection.Transferred += playToConnectionTransferred;

    e.SourceRequest.SetSource(controller);
}
catch (Exception ex)
{
    messageBlock.Text += "Exception encountered: " + ex.Message + "\n";
}
    }

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

    private void sourceSelectedHandler(
Windows.Media.PlayTo.PlayToManager sender,
Windows.Media.PlayTo.PlayToSourceSelectedEventArgs e)
    {
if (mediaElement.Name == "iplayer") {
    if (!e.SupportsImage) {
        messageBlock.Text += e.FriendlyName + " does not support streaming images. " +
                             "Please select a different device.";
        return;
    }
}

if (mediaElement.Name == "vplayer") {
    if (!e.SupportsVideo) {
        messageBlock.Text += e.FriendlyName + " does not support streaming video. " +
                             "Please select a different device.";
        return;
    }
}

if (mediaElement.Name == "aplayer") {
    if (!e.SupportsAudio) {
        messageBlock.Text += e.FriendlyName + " does not support streaming audio. " +
                             "Please select a different device.";
        return;
    }
}

Windows.Storage.Streams.IRandomAccessStream iconStream = e.Icon;
Windows.UI.Xaml.Media.Imaging.BitmapImage iconBitmap = 
        new Windows.UI.Xaml.Media.Imaging.BitmapImage();
iconBitmap.SetSource(iconStream);
playToDeviceIconImage.Source = iconBitmap;

playToDeviceFriendlyNameBlock.Text = e.FriendlyName;
    }

    private void playToConnectionError(
Windows.Media.PlayTo.PlayToConnection connection,
Windows.Media.PlayTo.PlayToConnectionErrorEventArgs e)
    {
if (e.Code == Windows.Media.PlayTo.PlayToConnectionError.DeviceError ||
    e.Code == Windows.Media.PlayTo.PlayToConnectionError.DeviceNotResponding) 
{
    messageBlock.Text += "Error occurred. Disconnecting.\n";
}

messageBlock.Text += "Error: Message = " + e.Message.ToString() + "\n";
    }

   private void playToConnectionStageChanged(
       Windows.Media.PlayTo.PlayToConnection connection, 
       Windows.Media.PlayTo.PlayToConnectionStateChangedEventArgs e) 
    {
messageBlock.Text += "StateChanged: PreviousState = " + e.PreviousState.ToString() + "\n";
messageBlock.Text += "StateChanged: CurrentState = " + e.CurrentState.ToString() + "\n";
    }

   private void playToConnectionTransferred(
       Windows.Media.PlayTo.PlayToConnection connection, 
       Windows.Media.PlayTo.PlayToConnectionTransferredEventArgs e)
    {
messageBlock.Text += "Transferred: PreviousSource = " + e.PreviousSource.ToString() + "\n";
messageBlock.Text += "Transferred: CurrentSource = " + e.CurrentSource.ToString() + "\n";
    }


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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

Attributes

[Deprecated()]
[Version(0x06020000)]

See also

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

 

 

Show: