• js 打开摄像头方法 (定制摄像头)


    var video = document.getElementById("video");
    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
        navigator.mediaDevices.getUserMedia({
            video: true,
            audio: true
        }).then(function(stream) {
            console.log(stream);
            mediaStreamTrack = typeof stream.stop === 'function' ? stream : stream.getTracks()[1];
        video.src = (window.URL || window.webkitURL).createObjectURL(stream);
            video.play();
        }).catch(function(err) {
            console.log(err);
    })
    }

      

    第二种

    //媒体对象
    	    window.navigator.getMedia = window.navigator.getUserMedia ||
    	                         window.navigator.webkitGetUserMedia ||
    	                         window.navigator.mozGetUserMedia ||
    	                         window.navigator.msGetUserMedia;
    	    window.navigator.getMedia({
    	        video: true, //使用摄像头对象
    	        audio: false  //不适用音频
    	    }, function(strem){
    	        console.log(strem);
    	        video.src = vendorUrl.createObjectURL(strem);
    	        video.play();
    		     
    	    }, function(error) {
    	        console.log(error);
    	    });
    

      

    转载自:https://www.cnblogs.com/imwtr/p/6413595.html

  • 相关阅读:
    python基础 2
    python基础 1
    进程
    进程作业
    上海python14期第二次阶段性考试
    面向对向之元类
    面向对向
    笔试题
    模块(2)
    模块作业
  • 原文地址:https://www.cnblogs.com/MainActivity/p/8581034.html
Copyright © 2020-2023  润新知