简体   繁体   English

iOS设备上的Azure Media Player

[英]Azure Media Player on iOS devices

I'm streaming O365 videos using Azure Media Player in a web app that must be used only in mobile devices. 我正在Web应用程序中使用Azure Media Player流O365视频,该应用程序只能在移动设备中使用。 It works with WP and Android, but the player stuck on iOS. 它可与WP和Android一起使用,但播放器卡在iOS上。

This is my code 这是我的代码

client.DefaultRequestHeaders.Add("Authorization", "Bearer " + bearer);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var response = await client.GetAsync($"{url}/GetPlaybackUrl('1')");
            var content = await response.Content.ReadAsStringAsync();
            var firstVal = JsonConvert.DeserializeObject<VideoToken>(content);

            response = await client.GetAsync($"{url}/GetStreamingKeyAccessToken");
            content = await response.Content.ReadAsStringAsync();
            var secondVal = JsonConvert.DeserializeObject<VideoToken>(content);

Client Side 客户端

<video id="newsVideoAMP" class="azuremediaplayer amp-default-skin amp-big-play-centered" tabindex="0"></video>

var initVideoPlayer = function (playbackUrl, streamingKeyAccessToken) {
    try {
        var myOptions = {
            "nativeControlsForTouch": false,
            controls: true,
            autoplay: false,
            techOrder: ["azureHtml5JS", "flashSS", "html5FairPlayHLS", "silverlightSS", "html5"],
            logo: { enabled: false }
        }
        newsVideoPlayer = amp("newsVideoAMP", myOptions,
            function () {
                this.addEventListener(amp.eventName.error, function () {
                    window.alert('error');
                    console.log('Error: amp init');
                    var errorDetails = newsVideoPlayer.error();
                    window.alert(errorDetails);
                    var code = errorDetails.code;
                    var message = errorDetails.message;
                    $("#log").append("<li><span>code: " + code + " - detail: " + message + "</span></li>')");
                });
            });
        newsVideoPlayer.src([
            {
                "src": playbackUrl,
                "type": "application/vnd.ms-sstr+xml",
                "protectionInfo": [
                    {
                        "type": "AES",
                        "authenticationToken": streamingKeyAccessToken
                    }
                ]
            }]);
    }
    catch (err) {
        console.log(err);
    }
}

I think the issue is related to video encoding. 我认为该问题与视频编码有关。 So I tried to use GetPlaybackUrl('0') (and avoid the next token request), but the player stops to work on WP and Android and still not work on iOS. 因此,我尝试使用GetPlaybackUrl('0') (并避免了下一个令牌请求),但是播放器停止在WP和Android上运行,而在iOS上仍然无法运行。

The logger in callback function doesn't tell me some useful and I have also tried to change the tech order. 回调函数中的记录器没有告诉我一些有用的信息,我还尝试了更改技术顺序。

Is there a console to manage video encoding in order to avoid the AES algorithm and the decrypt token? 是否有一个用于管理视频编码的控制台,以避免AES算法和解密令牌? Because this doc explain that iOS works with HTML5 tech will no token request. 因为此文档说明iOS与HTML5技术一起使用,因此不会请求令牌。 How can I solve? 我该如何解决? Thanks 谢谢

I found a workaround to reproduce videos on iOS devices. 我找到了一种解决方法,可以在iOS设备上重现视频。 Instead of use REST API I put an iframe element in my page with the video embedded. 我没有使用REST API,而是在页面中放置了嵌入视频的iframe元素。 Like this (using MVC Razor): 像这样(使用MVC Razor):

var url = "{YourWebsiteUrl}/portals/hub/_layouts/15/VideoEmbedHost.aspx?chId={YourChannelId}&vId={YourVideoId}&width=853&height=480&autoPlay=false&showInfo=false";

<iframe width=853 height=480 id="videoframe" src="@url" allowfullscreen data-spresponsive style='position: absolute; top: 0; left: 0; right: 0; bottom: 0; height: 100%; max-width: 100%;'></iframe>

I get this code from the popup of "embed" menu in the video page of Office365 Video. 我从Office365视频的视频页面中的“嵌入”菜单的弹出窗口中获取此代码。

If somebody else knows another (and better) method, please let me know. 如果其他人知道另一种(更好的方法),请告诉我。 Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM