当前,我很难将AAD与Azure媒体服务集成。 我必须从AAD获取承载令牌,然后将该令牌传递给Azure Media Player来播放加密的视频,但是我始终会遇到以下错误:无法解密加密的视频源。 (0x20500004)。
这里有两个我正在使用的代码片段。 C#代码:
string tenant = "xxxxxxxxxcom.onmicrosoft.com";
string clientId = "xxxxxxxx-xxxx-xxx-xxxx-xxxxxxxxxxx";
string clientSecret = "xxxXXXXXXXXXXXXXXXXXXXXXXXxxxx=";
var tokenCredentials = new AzureAdTokenCredentials(tenant, new AzureAdClientSymmetricKey(clientId, clientSecret), AzureEnvironments.AzureCloudEnvironment);
var tokenProvider = new AzureAdTokenProvider(tokenCredentials);
var token = tokenProvider.GetAccessToken();
C# Code Integration With Azure AAD
“ Microsoft.WindowsAzure.MediaServices.Client”版本为4.1
Asp.net/JavaScript代码:
<script>
var playerOptions = {
"nativeControlsForTouch": false,
controls: true,
autoplay: true,
width: "100%",
height: "auto",
techOrder: ["azureHtml5JS", "flashSS", "html5FairPlayHLS", "silverlightSS", "html5"],
logo: {
enabled: true
},
poster: "https://xxxxxxxxxx.blob.core.windows.net/assetxxxxxxxx-xxxx-410d-xxxx-7xxxxxxxxxxxx/xxxxx11563.jpg?sv=2015-07-08&sr=c&si=xxxxxx-xxxx-xxxxxxx-xxxxxx&sig=xxxxxxxxxxxxxxxb%2F%2FTlyHLU6DTcf%2FdfWMaMSqw%3D&se=2078-06-12T16%3A08%3A03Z",
plugins: {
ga: {
'eventsToTrack': ['playerConfig', 'loaded', 'playTime', 'percentsPlayed', 'start', 'end', 'play', 'pause', 'error', 'buffering', 'fullscreen', 'seek', 'bitrate'],
'debug': false
}
}
};
var playerSrc = [{
src: "http://xxxxxxxxx.streaming.mediaservices.windows.net/xxxxxx-xxx-xxxx-xxx-xxxx/xxxxxx.ism/manifest" + "(format=m3u8-aapl)",
"type": "application/vnd.ms-sstr+xml",
"protectionInfo": [{
"type": "AES",
"authenticationToken": "Bearer @ViewBag.Token"
}],
"streamingFormats":["SMOOTH","DASH"]
}];
</script>
Azure Player的链接是:https://ampdemo.azureedge.net/azuremediaplayer.html
答案 0 :(得分:0)
最后,我弄清楚了如何解决这个问题。请按照我执行的步骤操作:
选择您的视频源,然后单击右键。选择“编码使用Media Encoder Standard(MES)编码资产”。
选择“内容自适应多比特率MP4”,然后单击“启动编码”。 Img for step 3
现在是C#代码(对不起,我不知道为什么未采用该代码格式):
string tokenTemplateString =“ {{在此处粘贴您在第10步获得的XML(限制要求)}}”“”;
TokenRestrictionTemplate tokenTemplate =
TokenRestrictionTemplateSerializer.Deserialize(tokenTemplateString);
字符串testToken = TokenRestrictionTemplateSerializer.GenerateTestToken(tokenTemplate,tokenTemplate.PrimaryVerificationKey,新Guid(“在此处粘贴您在步骤10获得的ID。删除“ nb:kid:UUID:”部分!”),DateTime.Now.AddHours(10 ));
Console.WriteLine(“授权令牌为:\ nBearer {0}”,testToken);
在步骤12标记的字段中使用生成的令牌。请不要忘记使用单词“ Bearer”