我正在使用JWPlayer从Azure Blob存储流式传输视频,JWPlayer需要crossdomain.xml
才能播放视频。
我试图将crossdomain.xml
文件放在根目录中,并将代码放在http://127.0.0.1:10000/devstoreaccount1/crossdomain.xml
中,但JWPlayer在http://127.0.0.1:10000/crossdomain.xml
中查找它。
无论如何,是否将JWPlayer重定向到http://127.0.0.1:10000/devstoreaccount1/crossdomain.xml
而不是默认的http://127.0.0.1:10000/crossdomain.xml
?
最佳答案
我经常使用以下代码片段创建Crossdomainpolicy:
var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings[ConfigKey]);
var blobs = account.CreateCloudBlobClient();
CreateCrossDomainPolicy(blobs);
private static void CreateCrossDomainPolicy(CloudBlobClient blobs)
{
try
{
blobs.GetContainerReference("$root").CreateIfNotExist();
blobs.GetContainerReference("$root").SetPermissions(
new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
var blob = blobs.GetBlobReference("clientaccesspolicy.xml");
blob.Properties.ContentType = "text/xml";
blob.UploadText(@"<?xml version=""1.0"" encoding=""utf-8""?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-methods=""*"" http-request-headers=""*"">
<domain uri=""*"" />
<domain uri=""http://*"" />
</allow-from>
<grant-to>
<resource path=""/"" include-subpaths=""true"" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>");
}
catch (Exception Ex)
{
throw Ex;
}
}
我将在ConfigKey中传递我的实际Azure存储帐户密钥或Uselocalstorage = true