从Azure的Blob存储视频流 [英] Streaming video from Azure blob storage

查看:1547
本文介绍了从Azure的Blob存储视频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在获得存储在Azure的Blob存储在托管在Azure上一个网站,以显示一个 .MP4 视频问题。视频类型设置为视频/ MP4 ,存储帐户是不公开的,但它与网络的作用,我已经更新使用该位版本code:

I'm having problems getting an .mp4 video stored in Azure blob storage to show in a website hosted on Azure. The video type is set to video/mp4, the storage account is not public, but it is linked to the web role, and I've updated the version using this bit of code:

var credentials = new StorageCredentials("myaccountname", "mysecretkey"); 
var account = new CloudStorageAccount(credentials, true); 
var client = account.CreateCloudBlobClient(); 
var properties = client.GetServiceProperties(); 
properties.DefaultServiceVersion = "2012-02-12"; 
client.SetServiceProperties(properties); 

我不使用任何视频播放器,只需HTML5视频标签。我也并不需要任何幻想,我只想视频播放。

I'm not using any video player, just the HTML5 video tag. I also don't need anything fancy, I just want the video to play.

在Chrome的开发工具的网络标签看,有对 GET 请求获取视频的两个项目。第一个具有的状态(待定)键,下一个是(取消)

Looking at the network tab in Chrome's dev tools, there are two entries for the GET request to fetch the video. The first one has a status of (pending) and the next one is (canceled).

我也给它一个链接到一个视频这是在网站的内容文件夹。这其中也开始为挂起,但与 204部分内容解决和视频播放就好了。

I also gave it a link to a video which is in the website's content folder. This one also starts as pending but is resolved with a 204 Partial Content and the video plays just fine.

我出东西来看待,任何帮助和指针AP preciated。

I'm out of stuff to look at, and any help and pointers are appreciated.

推荐答案

根据您的上述评论,你需要的是一个的 共享访问签名 。使用下面的code在您的MP4文件创建一个共享访问签名。

Based on your comments above, what you need is a Shared Access Signature. Use the code below to create a shared access signature on your mp4 file.

        var credentials = new StorageCredentials("myaccountname", "mysecretkey");
        var account = new CloudStorageAccount(credentials, true);
        var container = account.CreateCloudBlobClient().GetContainerReference("yourcontainername");
        var blob = container.GetBlockBlobReference("yourmp4filename");
        var sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
        {
            Permissions = SharedAccessBlobPermissions.Read,
            SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),//Set this date/time according to your requirements
        });
        var urlToBePlayed = string.Format("{0}{1}", blob.Uri, sas);//This is the URI which should be embedded in your video player.

这篇关于从Azure的Blob存储视频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆