Skip to content

Commit cbff202

Browse files
committed
全屏播放
1 parent 05bb0b5 commit cbff202

2 files changed

Lines changed: 5 additions & 24 deletions

File tree

‎main.js‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ const videoElement = document.querySelector('video');
44
const videoSelect = document.querySelector('select#videoSource');
55
const 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-
167
function gotDevices(deviceInfos) {
178
const values = selectors.map(select => select.value);
189
selectors.forEach(select => {
@@ -74,9 +65,4 @@ function start() {
7465

7566
videoSelect.onchange = start;
7667

77-
start();
78-
79-
//拍照
80-
photograph.addEventListener("click", () => {
81-
context1.drawImage(video, 0, 0); //将video对象内指定的区域捕捉绘制到画布上指定的区域,实现拍照。
82-
})
68+
start();

‎userMedia.html‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
margin: 20px auto;
4242
}
4343

44-
.video,
45-
.canvas {
46-
border: 1px solid #d0d0d5;
44+
.video {
45+
width: 100%;
46+
height: 100%;
4747
}
4848
</style>
4949

@@ -54,12 +54,7 @@
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>

0 commit comments

Comments
 (0)