不支持IE浏览器(需要使用flash插件), 支持移动端, 未经过完全测试
PC端使用的时候, HTML页面需要预留video标签, canvas标签
移动端使用的时候, HTML页面需要预留file标签, canvas标签, img标签
(function (window, document) { window.camera = { init: function (options) { /** * options 属性示例 * videoID: video控件ID * canvasID: canvas控件ID * fileID: type为file的input控件的ID * imageID: img控件的ID * videoEnable: 是否启用摄像头 * audioEnable: 是否启用麦克风 * videoWidth: 视频宽度 * videoHeight: 视频高度 * photoWidth: 拍照宽度 * photoHeight: 拍照高度 */ _options = options; if (isMobileTerminal()) { initMobileTerminal(); } else { initComputerTerminal(); } }, photo: function () { if (isMobileTerminal()) { photoMobileTerminal(); } else { photoComputerTerminal(); } } }; let _options = null; function initComputerTerminal() { let videoDom = document.getElementById(_options.videoID); if (!videoDom) { alert('Video 控件无效'); return; } let canvasDom = document.getElementById(_options.canvasID); if (!canvasDom) { alert('Canvas 控件无效'); return; } canvasDom.setAttribute('width', _options.photoWidth + 'px'); canvasDom.setAttribute('height', _options.photoHeight + 'px'); let parameters = { video: _options.videoEnable "2d"); context.drawImage(imageDom, 0, 0, _options.photoWidth, _options.photoHeight); }, 300); }; reader.readAsDataURL(file); }); } function photoMobileTerminal() { let fileDom = document.getElementById(_options.fileID); fileDom.click(); } function isMobileTerminal() { if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || /Mobile/.test(navigator.userAgent) || /MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent)) return /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent); return false; } })(window, document);
以上就是js调用网络摄像头的方法的详细内容,更多关于js调用网络摄像头的资料请关注其它相关文章!
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com
暂无“js调用网络摄像头的方法”评论...
更新日志
2024年05月20日
2024年05月20日
- 张琍敏1978-雪中莲[台湾复刻版][WAV+CUE]
- 叶蕴仪1993-睡美人[日本版][WAV+CUE]
- 夜晚助兴音乐-群星《新时代床头音乐-性能量》2CD[WAV]
- 24K德国HD金碟《历届奥斯卡获奖金曲》3CD[WAV整轨]
- 邰正宵《重燃爱恋 贰 Walk On》[FLAC/分轨][431.72MB]
- 苏文劭《雨停出来走走》[320K/MP3][81.11MB]
- 苏文劭《雨停出来走走》[FLAC/分轨][210.76MB]
- 群星《2024好听新歌04》十倍音质WAV分轨
- 陈宁《弹指之间HQ》头版限量[低速原抓WAV+CUE]
- 陈宁《故人还》HQCDII限量签名版[低速原抓WAV+CUE]
- 苏文劭《春曲(Lessons)》[320K/MP3][39.8MB]
- 苏文劭《春曲(Lessons)》[FLAC/分轨][97.78MB]
- 群星《2006香港高级视听展原音精选 SACD》[ISO][2G]
- 张琍敏1977-枫林小雨[台湾复刻版][WAV+CUE]
- 林一峰2014-COOKINGMUSIC[香港首版][WAV+CUE]