【问题标题】:Access path for crossdomain.xml file for jwplayerjwplayer的crossdomain.xml文件的访问路径
【发布时间】:2012-04-15 07:10:00
【问题描述】:

我正在使用 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

【问题讨论】:

    标签: asp.net cross-domain flash jwplayer azure-blob-storage


    【解决方案1】:

    我经常使用这段代码sn-p来创建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

    【讨论】:

      【解决方案2】:

      您可以尝试将网络服务器配置为从文档根目录中的任何位置获取,我假设它位于/devstoreaccount/,文件位于并在请求/crossdomain.xml 时返回它。

      或者,您可以符号链接/devstoreaccount/crossdomain.xml --> /crossdomain.xml。如果它以某种方式链接到/devstoreaccount/crossdomain.xml.,这不会破坏您的代码

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-29
        • 2021-07-21
        • 2020-06-10
        相关资源
        最近更新 更多