This project is read-only.

Project Description

This project is to provide a simple, clean method to detect Zune connection dynamically by monitoring the network interface list.


I was developing a photo viewer based on XNA and needed a way to quickly and precisely check whether the MediaLibrary is locked up by Zune. Unfortunately, Microsoft does not provide such a method, although its own Apps, such as Album, does very well in this way. So I googled to find out how other developers deal with this problem.
There are several workarounds:

  • Test NetworkInterfaceType being Ethernet
  • Handle resulting exceptions
  • Save a jpg to media library and catch the exception
  • Use PhotoChooserTask

According to my tests, except for the first one, other approaches are all infeasible. And luckily, there is already a project focusing on this - Zune Detection and Network Awareness. I downloaded the source code and did a lots of tests. Unfortunately again, the code has some defects which causes the result totally unacceptable in some scenarios. For example, sometimes the detection costs over 60 seconds! Or when the connected computer has no Ethernet connection and the phone in a mobile network, the returned NetworkType is None! Of course, these problems are not caused by the project code but by Microsoft's shabby API. Here's my advice:

  Don't use Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType!

Although this project is out of my options, but it inspired me! I looked up MSDN and found WP7 actually has other APIs to check the network connections:


These APIs can quickly list all current network interfaces, and all I need to do is to check if a Zune connection is among them, which I found can be very easy since Windows Phone is not allowed to be used as a USB drive so an established USB connection must be Zune! It's not theoretically perfect but practically workable!


Last edited Jun 26, 2012 at 5:47 AM by JackieWang, version 3