创建 OnDemand 流媒体定位器时如何指定不同的流媒体端点
How To Specify Different Streaming Endpoint When Creating An OnDemand Streaming Locator
我定义了两个 Azure 媒体流终结点:默认终结点是在 2014 年 9 月 11 日之前创建的并且不支持 https,而新的流终结点是在 2014 年 9 月 11 日之后创建的并且支持 https。
我已从默认流式处理端点删除所有流式处理单元并关闭默认流式处理端点。新的流式处理终结点已启用并具有单个流式处理单元。
当我为我的资产创建定位器时,我需要定位器到 return 新流端点的基本 uri,但是它 return 是默认流端点的基本 uri。例如:
var locator = mediaContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, asset, policy, DateTime.UtcNow.AddMinutes(-5));
// locator.BaseUri == http://example.origin.mediaservices.windows.net
// This uri points to the default streaming endpoint
在为我的资产创建新定位器时,如何指定要使用的流媒体端点?
定位器 (GUID) 对您的 Azure 媒体服务帐户中的所有流式处理终结点有效。要使用您的 "new" 流媒体端点,请获取定位器 URL 并将其更改为使用 "new" 主机名。
这就是我在 AMS Explorer 中所做的(参见资产信息/定位器)。 http://aka.ms/amse
string hostname = myNewSE.HostName;
UriBuilder urib = new UriBuilder()
{
Host = hostname,
Path = locator.AbsolutePath,
};
return urib.Uri;
原来我使用的是旧版本的 Azure 媒体服务客户端 SDK (v3.0.0.5)。在较新的版本中,MediaContext class 有一组流媒体端点,可以轻松找到您所追求的端点。我最终解决这个问题的方法如下:
public void Example(CloudMediaContext mediaContext, IAsset asset)
{
var policy = mediaContext.AccessPolicies.Create("Streaming policy", MaxMediaAccessPeriod, AccessPermissions.Read);
var locator = mediaContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, asset, policy, DateTime.UtcNow.AddMinutes(-5));
var template = new UriTemplate("{contentAccessComponent}/");
var result = mediaContext.StreamingEndpoints
.AsEnumerable()
.Where(x => x.State == StreamingEndpointState.Running)
.Select(x => template.BindByPosition(new Uri("https://" + x.HostName), locator.ContentAccessComponent))
.First();
}
我在 this blog post 中找到了我需要的信息。
我定义了两个 Azure 媒体流终结点:默认终结点是在 2014 年 9 月 11 日之前创建的并且不支持 https,而新的流终结点是在 2014 年 9 月 11 日之后创建的并且支持 https。
我已从默认流式处理端点删除所有流式处理单元并关闭默认流式处理端点。新的流式处理终结点已启用并具有单个流式处理单元。
当我为我的资产创建定位器时,我需要定位器到 return 新流端点的基本 uri,但是它 return 是默认流端点的基本 uri。例如:
var locator = mediaContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, asset, policy, DateTime.UtcNow.AddMinutes(-5));
// locator.BaseUri == http://example.origin.mediaservices.windows.net
// This uri points to the default streaming endpoint
在为我的资产创建新定位器时,如何指定要使用的流媒体端点?
定位器 (GUID) 对您的 Azure 媒体服务帐户中的所有流式处理终结点有效。要使用您的 "new" 流媒体端点,请获取定位器 URL 并将其更改为使用 "new" 主机名。 这就是我在 AMS Explorer 中所做的(参见资产信息/定位器)。 http://aka.ms/amse
string hostname = myNewSE.HostName;
UriBuilder urib = new UriBuilder()
{
Host = hostname,
Path = locator.AbsolutePath,
};
return urib.Uri;
原来我使用的是旧版本的 Azure 媒体服务客户端 SDK (v3.0.0.5)。在较新的版本中,MediaContext class 有一组流媒体端点,可以轻松找到您所追求的端点。我最终解决这个问题的方法如下:
public void Example(CloudMediaContext mediaContext, IAsset asset)
{
var policy = mediaContext.AccessPolicies.Create("Streaming policy", MaxMediaAccessPeriod, AccessPermissions.Read);
var locator = mediaContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, asset, policy, DateTime.UtcNow.AddMinutes(-5));
var template = new UriTemplate("{contentAccessComponent}/");
var result = mediaContext.StreamingEndpoints
.AsEnumerable()
.Where(x => x.State == StreamingEndpointState.Running)
.Select(x => template.BindByPosition(new Uri("https://" + x.HostName), locator.ContentAccessComponent))
.First();
}
我在 this blog post 中找到了我需要的信息。