This project is read-only.

PlayTo media sharing functionality raises a threading Exception on SetSource

Topics: Windows 8 Xaml
May 10, 2012 at 12:02 PM
Edited May 10, 2012 at 12:10 PM


I'm trying to use the PlayTo functionality in my metro app using the Media Player last release (Preview 2), but when I set the PlayTo source request, I fall into a threading exception, that seems to be raised by the PlayToSource property:

The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)) 

at Windows.UI.Xaml.DependencyObject.GetValue(DependencyProperty dp) 
at Microsoft.PlayerFramework.MediaPlayer.get_PlayToSource()

Thinking that was because of my app, I switched to Microsoft's PlayTo sample and tried it on that: the sample works fine, but when I replace the Xaml Media Player with the PlayerFramework one it raises the above exception again.

Is there any known issue on that? Any workaround?

Thanks for your help,


May 21, 2012 at 9:19 PM

Nicola, I see the PlayTo sample on MSDN added a note about needing to use a dispatcher when accessing the PlayTo sample. The fundamental issues is that MediaPlayer.PlayToSource is a dependency property and dependency properties can only be accessed from the UI thread.

I'm not sure why MediaElement would work however because it also uses a dependency property. Please try the dispatcher trick and let me know if you still have problems.