简体   繁体   English

当来源是IE / EDGE上的加密令牌视频时,Canvas无法从Azure Media Player中绘制Image

[英]Canvas not drawImage from azure media player when source is encrypted token video on IE/EDGE

My application works fine in Chrome, but in IE/EDGE the canvas doesnt show the video. 我的应用程序在Chrome中可以正常运行,但是在IE / EDGE中,画布无法显示视频。

This started to happen when i use as source a encrypted video, when i used open source video the canvas showed the video. 当我使用加密视频作为源时,当我使用开源视频时,画布显示了视频,这开始发生。 I cant find a solution mostly because IE/EDGE doesnt show errors in developer tools console. 我找不到解决方案,主要是因为IE / EDGE在开发人员工具控制台中未显示错误。

IE/EDGE has some policy that doesnt allow to draw a encrypted video? IE / EDGE的某些政策不允许绘制加密的视频?

In future i will remove video element from html, create only in javascript and write some text in canvas as a watermark. 将来,我将从html中删除视频元素,仅在javascript中创建,然后在画布上写一些文本作为水印。

<canvas runat="server" id="canvas1"></canvas>
<video 
    id="video1" 
    runat="server" 
    class="azuremediaplayer amp-default-skin amp-big-play-centered" 
    controls 
    poster="">
</video>

<script>
    var videoElement = document.getElementById('<%=video1.ClientID%>');
    videoElement.setAttribute('webkit-playsinline', 'true');
    videoElement.width = '1280';
    videoElement.height = '720';
    var x, y, min, tempo = 0;
    var nroRender = 201;
    var myPlayer = amp(videoElement);
    myPlayer.src([{
        src: '<URL VIDEO>',
        protectionInfo: [
        {
            type: 'Widevine',
            authenticationToken: 'Bearer=<TOKEN>'
        }, {
            type: 'PlayReady',
            authenticationToken: 'Bearer=<TOKEN>'
        }]
    }]);

    var canvasElement = document.getElementById('<%=canvas1.ClientID%>');
    canvasElement.width = '1280';
    canvasElement.height = '720';
    var ctx = canvasElement.getContext('2d');

    function desenha() {
        ctx.clearRect(0, 0, canvasElement.width, canvasElement.height);
        ctx.drawImage($('#video1 video')[0], 0, 0, canvasElement.width, canvasElement.height);
    }

    function loop() {
        desenha();
        setTimeout(loop, 1000 / 60);
    }

    loop();
</script>

If you have some problem to understand what is the problem, run in Chrome and then in IE. 如果您有任何问题要了解问题所在,请先在Chrome中运行,然后在IE中运行。 In Chrome canvas appears like video, in IE canvas appears black. 在Chrome画布中,它看起来像视频,在IE画布中,看起来像黑色。

Full code in https://github.com/tobiasrighi/video-canvas/blob/master/WebForm1.aspx 完整代码在https://github.com/tobiasrighi/video-canvas/blob/master/WebForm1.aspx

Because the video is protected with DRM, by design IE/Edge block the ability to capture frames - its actually not an error and this is built down lower in the media pipeline. 由于视频受DRM保护,因此通过设计IE / Edge可以捕获帧的能力-实际上这不是错误,并且在媒体管道中的位置较低。 It seems Chrome's current implementation with Widevine does not block frames, although this may happen in the near future depending on Google's future design considerations. Chrome当前使用Widevine的实现似乎不会阻止框架,尽管这可能会在不久的将来发生,具体取决于Google未来的设计考虑。

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

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