Problem with video download using GetVideoUri

Nov 8, 2012 at 7:44 PM
Edited Nov 8, 2012 at 8:10 PM


I'm trying to use Youtube.GetVideoUri directly in my app to download youtube videos using a WebClient, but I'm getting some exceptions thrown when I start the download.

My code is something like this:


YouTube.GetVideoUri(YoutubeVideoId, YouTubeQuality.Quality720P, (entry, excep) =>
          if (excep != null)
              //this is not the place where I get exceptions
              if (entry != null)
		  //here starts the download


This code is similar to YouTube.Play, and I'm getting the Uri just fine through the Debug. But when the download starts, I get System.IO.FileNotFoundException and System.UnauthorizedAccessException. The thing is: this Uri is the same when you Debug the Uri inside Youtube.Play, and it works inside there with the MediaPlayerLauncher, but not in my code. Does anybody know what I could be missing when using the GetVideoUri response? Thanks.

Nov 9, 2012 at 12:46 PM

In Silverlight you cannot download files from URIs which are not in your domain.


Nov 9, 2012 at 3:57 PM

Thanks for the reply, rsuter. Actually, I found another way to download the Uri provided by GetVideoUri. Now I'm using HttpWebRequest instead of WebClient, and it works fine.

Anyway, maybe these security restrictions can be a barrier to my certification process in Dev Center, it surely is a worth reading.

Nov 9, 2012 at 3:59 PM

The problem is only with Silverlight "Web" applications. I think in Windows Phone you won't get a problem... You can also use the MyToolkit's http classes: