[英]How to programmatically change the read policy for azure media service locator?
In adding the locators to several files I uploaded to azure media service, I mistakenly, added and set the wrong expiration time on the mp4 files. 在将定位器添加到我上传到azure媒体服务的几个文件中时,我错误地在mp4文件上添加并设置了错误的到期时间。 I am also storing the information for each uploaded file in the database, including the links to the locator.
我还将每个上载文件的信息存储在数据库中,包括指向定位器的链接。 Is there a way I can reset the expiration time on the locators for each file I currently have stored in media services and be able to retrieve the new locators for each file?
有什么方法可以为我当前存储在媒体服务中的每个文件的定位器上的过期时间重置,并能够为每个文件检索新的定位器?
Create locator API can get locatorID as a parameter. 创建定位器API可以获取locatorID作为参数。 You need to get existing locator and delete it and then create with the same GUID so you can update the expire date and also keep the same locator(URL).
您需要获取现有的定位器并将其删除,然后使用相同的GUID创建,以便您可以更新到期日期并保留相同的定位器(URL)。
Here is a sample which will store existing locator details and recreate. 这是一个示例,它将存储现有的定位器详细信息并重新创建。
private static ILocator RecreateLocator(ILocator locator, CloudMediaContext mediaContext)
{
// Save properties of existing locator.
var asset = locator.Asset;
var accessPolicy = locator.AccessPolicy;
var locatorId = locator.Id;
var startDate = locator.StartTime;
var locatorType = locator.Type;
var locatorName = locator.Name;
// Delete old locator.
locator.Delete();
if (locator.ExpirationDateTime <= DateTime.UtcNow)
{
throw new Exception(String.Format(
"Cannot recreate locator Id={0} because its locator expiration time is in the past",
locator.Id));
}
// Create new locator using saved properties.
var newLocator = mediaContext.Locators.CreateLocator(
locatorId,
locatorType,
asset,
accessPolicy,
startDate,
locatorName);
Trace.TraceInformation("Locator created. Name={0}, path={1}", newLocator.Name, newLocator.Path);
return newLocator;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.