Win8 App : stream videos from a Windows Azure Blob storage

, , Comments Off on Win8 App : stream videos from a Windows Azure Blob storage

Videos are everywhere and specially in Windows 8 app. Using a Windows Azure’s blob to store them is a good solution and this what we choose in on of the app we build in my company (Infinite Square).

We uploaded the files in the blobs, used a MediaElement to play them but it seems like the video needed to be fully downloaded to be played. It was very frustating since the videos weighted dozen of Mbytes.

The solution is in the Cloud!

When you use Blob storage, you can actually set a default version for the API. It can be obvious for the Azure expert but not for me.

If you set this default version to “2011-08-18” then you will be able to do partial and pause/resume downloads on blob objects. This is exactly what we were looking for !

To do this, th only way I found was to create a little .NET program, reference the Azure SDK (thank you Nuget) and call the SetServiceProperties with the correct arguments.

string accountName = "your account Name";
string accountKey = "your account key";
var cloudStorageAccount = CloudStorageAccount
, accountName, accountKey));

CloudBlobClient client = cloudStorageAccount.CreateCloudBlobClient();

var prp = client.GetServiceProperties();
client.SetServiceProperties(new ServiceProperties()
DefaultServiceVersion = "2011-08-18",
Logging = prp.Logging,
Metrics = prp.Metrics



Now you just have to use the uri of the video in your XAML UI ( or with a video tag) :
<playerFramework:MediaPlayer Source="{Binding VideoUri}"
AutoLoad="False" />