seimin 1 week ago
parent
commit
5fce01f76b
2 changed files with 34 additions and 0 deletions
  1. 1 0
      src/app/views/login/login.component.html
  2. 33 0
      src/app/views/login/login.component.ts

+ 1 - 0
src/app/views/login/login.component.html

@@ -46,6 +46,7 @@
46
       <strong>点击下载谷歌浏览器👉</strong>
46
       <strong>点击下载谷歌浏览器👉</strong>
47
       <a [href]="http.domain+'/chrome64/ChromeSetup32.exe'">win32</a>
47
       <a [href]="http.domain+'/chrome64/ChromeSetup32.exe'">win32</a>
48
       <a [href]="http.domain+'/chrome64/ChromeSetup64.exe'">win64</a>
48
       <a [href]="http.domain+'/chrome64/ChromeSetup64.exe'">win64</a>
49
+      <a href="javascript:;" (click)="showScreen($event)">录屏</a>
49
     </div>
50
     </div>
50
   </div>
51
   </div>
51
 </div>
52
 </div>

+ 33 - 0
src/app/views/login/login.component.ts

@@ -9,6 +9,8 @@ import { baseUrlType } from "src/app/type/types";
9
 import { ToolService } from 'src/app/services/tool.service';
9
 import { ToolService } from 'src/app/services/tool.service';
10
 import { Title } from '@angular/platform-browser';
10
 import { Title } from '@angular/platform-browser';
11
 import { MarkingService } from 'src/app/services/marking.service';
11
 import { MarkingService } from 'src/app/services/marking.service';
12
+
13
+declare var MediaRecorder: any;
12
 @Component({
14
 @Component({
13
   selector: "app-login",
15
   selector: "app-login",
14
   templateUrl: "./login.component.html",
16
   templateUrl: "./login.component.html",
@@ -301,4 +303,35 @@ export class LoginComponent implements OnInit {
301
     });
303
     });
302
     return parents;
304
     return parents;
303
   }
305
   }
306
+
307
+  // 录屏
308
+  isRecording:boolean = false;
309
+  async showScreen(e){
310
+    if(this.isRecording){
311
+      return;
312
+    }
313
+    this.isRecording = true;
314
+    e.preventDefault();
315
+    let stream = await (navigator.mediaDevices as any).getDisplayMedia({ video: true });
316
+    let mime = MediaRecorder.isTypeSupported("video/webm; codecs=vp9") ? "video/webm; codecs=vp9" : "video/webm";
317
+
318
+    let mediaRecorder = new MediaRecorder(stream, { mimeType: mime });
319
+    let chunks = [];
320
+    //录制
321
+    mediaRecorder.addEventListener('dataavailable', function (e) {
322
+      chunks.push(e.data)
323
+    })
324
+    //停止
325
+    mediaRecorder.addEventListener('stop', function () {
326
+      let blob = new Blob(chunks, { type: chunks[0].type });
327
+      let url = URL.createObjectURL(blob);
328
+      let a = document.createElement('a');
329
+      a.href = url;
330
+      a.download = 'video.webm';
331
+      a.click();
332
+      this.isRecording = false;
333
+    })
334
+    //手动启动
335
+    mediaRecorder.start()
336
+  }
304
 }
337
 }