简体   繁体   English

我的视频实现无法在Firefox和Safari浏览器中使用; 仅镀铬

[英]My implementation of video doesn't work in firefox and safari; only chrome

<!DOCTYPE html>
<html land="en">
<head>
<meta charset="utf-8">
<title>Using video in the canvas tag</title>
<script type="text/javascript">

    var vid,ctx;

    function init(){
        window.addEventListener("resize",onResize,false);

        var can = document.getElementById('canvas1');
        ctx = can.getContext('2d');

        vid = document.createElement('video');
        vid.src = 'video.mp4';
        vid.autoplay = true;
        vid.loop = true;
        vid.addEventListener("canplaythrough", play, false);

    }


    function play(){
        setInterval(function() {
            ctx.drawImage(vid, 0, 0);
        }, 1000/23.976);
    }

</script>

<style type="text/css">
    body{margin:0;}
</style>

</head>


<body onLoad="init();">
    <canvas id="canvas1" width="1280" height="720"></canvas>

</body>


</html>

Im trying to get full screen video by scaling the canvas up, however the code above only works in Chrome. 我试图通过放大画布来获得全屏视频,但是上面的代码仅在Chrome中有效。 The video does not show up in firefox 10.0.2 nor safari 5.05. 该视频无法在Firefox 10.0.2和Safari 5.05中显示。 I tried three different files: mp4,ogv, and webm. 我尝试了三个不同的文件:mp4,ogv和webm。 What's wrong with my code. 我的代码有什么问题。 I know there is a tag but can I scale it the same way I can with a canvas? 我知道有一个标签,但是我可以像在画布上一样缩放它吗?

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

相关问题 jsPDF在Chrome中不起作用,只适用于Firefox和Safari - jsPDF doesn't work in Chrome, only Firefox & Safari JavaScript 在 Safari 中不起作用,但在 Firefox 和 Chrome 中起作用 - JavaScript doesn't work in Safari but does in Firefox and Chrome 音频/视频DOM错误事件在Chrome / Firefox中不起作用 - Audio/Video DOM error Event doesn't work in Chrome/Firefox 我的脚本无法在Mozilla Firefox上运行,但可以在Chrome上运行 - My scripts doesn't work on Mozilla Firefox but does on Chrome 我的音频可视化器在 chrome 中不起作用(但在 Firefox 中起作用) - My audio visualizer doesn't work in chrome (but does in firefox) 视频未预加载,Chrome和Firefox错误 - Video doesn't preload, error Chrome and Firefox ajax跨源请求在safari中不起作用,但在chrome和firefox中起作用 - ajax cross origin request doesn't work in safari but works in chrome and firefox 全屏切换在 iOS 手机/平板电脑(Safari、Chrome 和 Firefox)上不起作用 - Fullscreen toggle doesn't work on iOS mobile/tablet (Safari, Chrome and Firefox) $ .ajax async:false在IE和Firefox中不起作用,适用于Chrome / Safari - $.ajax async:false doesn't work in IE and Firefox, works in Chrome/Safari 全屏视频JS在Safari中不起作用 - Video JS Fullscreen Doesn't work in Safari
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM