Does anyone know a way to stream .mp4 video from a secure azure blob (via https) into a WPF application.
I'm generating the uri as follows ...
public Uri GetSecureUriForBlob(CloudBlobContainer container, string blobName)
{
var blockBlob = container.GetBlockBlobReference(blobName);
var beforeOffset = new DateTimeOffset(DateTime.UtcNow.AddMinutes(-5));
var afterOffset = new DateTimeOffset(DateTime.UtcNow.AddHours(1));
var builder = new UriBuilder(blockBlob.Uri)
{
Query = blockBlob.GetSharedAccessSignature(
new SharedAccessBlobPolicy
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessStartTime = beforeOffset,
SharedAccessExpiryTime = afterOffset
}).TrimStart('?')
};
return builder.Uri;
}
I've checked that the service version is set to at least "2013-08-15" and that the blob item has the correct content type set.
I know the format of the uri is correct, because I can paste it in a browser, and also use it in a Windows 8 store application, and the video streams correctly.
However, when I assign the same uri as the source for a WPF MediaElement, I get a NullReferenceException deep in the inner workings of MediaPlayer.Open().
There seems to be a known issue with WPF MediaElement when playing from HTTPS endpoints. There are no issues when playing over plain HTTP (without "S").
This is not Microsoft Azure related, or Blob Related. This is pure WPF issue, that however seems that will not be fixed soon, if fixed at all.
For HTTPS Streams you can use either Silverlight or Windows 8 Modern applications - both support HTTPS streams without any issues.
You could probably find a 3rd party control for WPF that supports playing media over HTTPS.
UPDATE
Using the VideoLan.NET WPF Controls I was able to make HTTPS media playing. So far the only controls for WPF that successfully play HTTPS media. This requires a valid installation of VideoLAN VLC player for Windows. I used the portable one (ZIP package) and it works perfectly. Documentation for the VideoLan.NET is a bit messy, but the result is that you can safely play HTTPS streams/progressive downloads in WPF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With