File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,15 +4,6 @@ const videoElement = document.querySelector('video');
44const videoSelect = document . querySelector ( 'select#videoSource' ) ;
55const selectors = [ videoSelect ] ;
66
7- let canvas = document . getElementById ( 'canvas' ) ;
8- let context1 = canvas . getContext ( '2d' ) ;
9-
10- videoElement . addEventListener ( 'canplay' , function ( ) {
11- canvas . width = this . videoWidth ;
12- canvas . height = this . videoHeight ;
13- console . log ( 'this' , this )
14- } ) ;
15-
167function gotDevices ( deviceInfos ) {
178 const values = selectors . map ( select => select . value ) ;
189 selectors . forEach ( select => {
@@ -74,9 +65,4 @@ function start() {
7465
7566videoSelect . onchange = start ;
7667
77- start ( ) ;
78-
79- //拍照
80- photograph . addEventListener ( "click" , ( ) => {
81- context1 . drawImage ( video , 0 , 0 ) ; //将video对象内指定的区域捕捉绘制到画布上指定的区域,实现拍照。
82- } )
68+ start ( ) ;
Original file line number Diff line number Diff line change 4141 margin : 20px auto;
4242 }
4343
44- .video ,
45- . canvas {
46- border : 1 px solid # d0d0d5 ;
44+ .video {
45+ width : 100 % ;
46+ height : 100 % ;
4747 }
4848 </ style >
4949
5454 < div class ="select ">
5555 < label for ="videoSource "> 切换摄像头: </ label > < select id ="videoSource "> </ select >
5656 </ div >
57-
58- < video id ="video " playsinline autoplay > </ video >
59-
60- < button title ="拍照 " id ="photograph "> 拍照</ button >
61-
62- < canvas id ="canvas " class ="canvas "> </ canvas >
57+ < video id ="video " class ="video " playsinline autoplay > </ video >
6358 </ div >
6459
6560 < script src ="https://webrtc.github.io/adapter/adapter-latest.js "> </ script >
You can’t perform that action at this time.
0 commit comments