Jelajahi Sumber

增加video apply强制大小与fameRate

gemercheung 1 tahun lalu
induk
melakukan
83ba55b73b

+ 1 - 1
packages/core/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@simaq/core",
-  "version": "1.1.8",
+  "version": "1.1.9",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 13 - 0
packages/core/src/lib/basicSimaqRecorder.ts

@@ -212,7 +212,20 @@ export class BasicSimaqRecorder extends EventEmitter {
                     defaultFrame = this.platformConfig.frameRate;
                 }
                 const stream = this.canvasElement.captureStream(defaultFrame);
+                // debugger;
                 if (stream) {
+                    const videoTrack = stream.getVideoTracks()[0];
+                    if (videoTrack) {
+                        videoTrack.applyConstraints({
+                            advanced: [
+                                {
+                                    width: videoConstraints.value.width,
+                                    height: videoConstraints.value.height,
+                                    frameRate: videoConstraints.value.frameRate,
+                                },
+                            ],
+                        });
+                    }
                     return resolve(stream);
                 }
                 return resolve(null);

+ 1 - 4
play/src/App.vue

@@ -44,11 +44,11 @@ videoRecorder.on('startRecord', () => {
 videoRecorder.on('record', (data: Blob) => {
     //录屏后片断数据
     console.log('record', data);
-    // handleAutoDownload([data]);
 });
 videoRecorder.on('endRecord', (data) => {
     console.log('endRecord', data);
     sound.stop();
+    handleAutoDownload([data]);
     //结束录屏event
 });
 videoRecorder.on('cancelRecord', () => {
@@ -74,7 +74,6 @@ const handleAutoDownload = async (chunks: Blob[]) => {
 };
 onMounted(() => {
     // const GoldPlay = (window as any).GoldPlay;
-
     // let el = document.querySelector('.play-container');
     // //播放器参数
     // let options = {
@@ -86,7 +85,6 @@ onMounted(() => {
     //     libPath: 'https://omc3i.codesandbox.io/',
     // };
     // let player = new GoldPlay(el, options);
-
     // const testFrame: HTMLIFrameElement = document.getElementById(
     //     'testFrame',
     // ) as HTMLIFrameElement;
@@ -102,7 +100,6 @@ onMounted(() => {
     //     console.log('testFrame-load', canvas);
     // };
     // testFrame.addEventListener('load', () => {
-
     //     if (canvas) {
     //         videoRecorder.updateCanvas(canvas);
     //     }