Posted by Motz on Nov 27, 2010 in Blog, Uncategorized | 0 comments
If you are using the Media Element and are streaming a piece of media via http it will usually work just fine in the emulator. Today I kept getting the AG_E_NETWORK_ERROR when I was developing on my WP7 LG Optimus 7. I was in debug mode and had the Optimus attached to my laptop. I was very confused as to why this was occurring and after a bunch of Bing searches I finally found out that all you have to do to get it working is disconnect the phone from your computer. Simply doing this made the stream work just fine! However this lead me to put in an error message when there was a problem streaming media. Simply add an event:
MediaFailed="myMediaElement_MediaFailed"
I added a simple TextBlock on the page and by default it is collapsed. When this event is hit I simply call the Dispatcher and make it visible:
TextBlockError.Dispatcher.BeginInvoke(delegate
{
TextBlockError.Visibility = System.Windows.Visibility.Visible;
});
Update:
In October, Microsoft released a few more Windows Phone tools. One of them is called WPConnect and this allows you to debug on your Windows Phone without having Zune running. This is great because it gets rid of this problem. You can download the tools from the Microsoft website and simply follow these steps.
1.) Plug in your phone
2.) Close Zune
3.) Open up a command prompt (cmd in windows search will bring it up)
4.) enter “cd C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect” this should bring you to the WPConnect folder. (if it is installed somwhere else enter the location)
5.) enter “wpconnect.exe” and it will run and you are all set.