Geoblocked video?

Topics: Windows 8 Xaml, Windows Phone 8
Feb 28, 2013 at 11:53 AM

my Windows Store app needs to display videos, which are geoblocked (i.e. not viewable from outside my country), any pointers as to how to catch those requests and/or test? I need to display the appropriate message in such cases, my app just failed certification because of this.

Feb 28, 2013 at 5:03 PM
The player will raise a MediaFailed event that you could capture to do something special. However, the question is whether or not you can distinguish this error from others (e.g. internet connection goes down). I'd start by looking at the MediaFailed's eventargs.ErrorMessage to see if it is unique in this scenario.

Assuming this is possible, the next step would be to display a message to the user. By default we ship a plugin (ErrorPlugin) that will get displayed when the player fails and allows the user to retry. You could disable this plugin and create your own custom version of this plugin (start by making a copy of ErrorPlugin.cs from our source code) and alter it to do something special depending on the nature of the error.

If it is not possible to get the info you need from the MediaFailed event, another route would be to request the URL beforehand in code and check the HTTP status code (or whatever part of the request indicates the URL is geo blocked). A good place to do this is in the MediaLoading event. For example:
 player.MediaLoading += player_MediaLoading;
async void player_MediaLoading(object sender, MediaPlayerDeferrableEventArgs e)
    var deferral = e.DeferrableOperation.GetDeferral();
    var client = new HttpClient();
    var result = await client.GetAsync(player.Source);
    if (IsGeoBlocked(result))
        // show a message to the user