HTML5——利用navigator+Video調用網路攝影機進行錄影,html5navigator

來源:互聯網
上載者:User

HTML5——利用navigator+Video調用網路攝影機進行錄影,html5navigator


             

       以前無聊的時候玩兒過HTML5,感覺裡面的很多新標籤確實深深震撼了我額。。。。


       今天需求那邊要做這樣一個功能,在裡面調用網路攝影機進行拍攝,然後上傳。剛開始最先想到的是Video標籤,只要將它的src指定為當前網路攝影機錄製到的視頻就可以了。


          後來百度了一段,發現還要用上Navigator,具體代碼如下:



             

<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <script type="text/javascript">        window.addEventListener("DOMContentLoaded", function () {            // Grab elements, create settings, etc.            var canvas = document.getElementById("canvas"),context = canvas.getContext("2d"),video = document.getElementById("video"),videoObj = { "video": true },errBack = function (error) {    console.log("Video capture error: ", error.code);};            //             if (navigator.getUserMedia) { // Standard                navigator.getUserMedia(videoObj, function (stream) {                    video.src = stream;                    video.play();                }, errBack);            } else if (navigator.webkitGetUserMedia) { // WebKit-prefixed引擎                navigator.webkitGetUserMedia(videoObj, function (stream) {                    video.src = window.webkitURL.createObjectURL(stream);                    video.play();                }, errBack);            }            else if (navigator.mozGetUserMedia) { // Firefox-prefixed                navigator.mozGetUserMedia(videoObj, function (stream) {                    video.src = window.URL.createObjectURL(stream);                    video.play();                }, errBack);            }        }, false);        </script></head>     <body>    <form id="form1" runat="server">    <div>        <video id="video" width="640" height="480" autoplay></video>        <button id="snap">Snap Photo</button>        <canvas id="canvas" width="640" height="480"></canvas>    </div>    </form></body></html>



         搞完之後同事大哥發布到伺服器上然後拿手機測試,發現裡面的瀏覽器是不支援網路攝影機調用的。。。額,,然後就我勒個去了。。。。。。。


         有用到的小夥伴可以拿到自己網站上玩兒玩兒。。。。








聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.