[Vue] Réalisez la fonction d'enregistrement d'écran et enregistrez-la localement

Un, Vue

Nous utilisons toujours le fichier Vue.js de l'article précédent

Ici, Vue implémente la fonction caméra

2. Créez un répertoire

filigrane, type_d3F5LXplbmhlaQ, shadow_50, text_Q1NETkDlsI_nmq7njKo, size_8, color_FFFFFF, t_70, g_se, x_16

3. Réalisation 

1. index.html

filigrane, type_d3F5LXplbmhlaQ, shadow_50, text_Q1NETkDlsI_nmq7njKo, size_20, color_FFFFFF, t_70, g_se, x_16

 

Code:

 



<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="vue.js"></script>
    </head>
    <body>
        < div id="vueapp">
            <div>
                <button @click="btnRecordClicked" :disabled="recording">录制</button>
                <button @click="btnPauseClicked" :disabled="paused||!recording">Plus </button>
                <button @click="btnResumeClicked" :disabled="!paused||!recording">Étape</button>
                <button @click="btnStopClicked" :disabled="!recording">Paramètre</bouton>
                <button :disabled="!currentWebmData" @click="btnPlayClicked">Paramètre</bouton>
            </div>
            <commandes vidéo ref="player"></video>
        </div>
        <script src="app.js"></script>
    </body>
</html>


2. app.js

filigrane, type_d3F5LXplbmhlaQ, shadow_50, text_Q1NETkDlsI_nmq7njKo, size_20, color_FFFFFF, t_70, g_se, x_16

code


 new Vue({     el:"#vueapp",     data:{         currentWebmData:0,         recording:false,         paused:false     },     monté() {         this._initApp();     },     methodes :{         async _initApp(){             // this ._stream=attendre navigator.mediaDevices.getUserMedia({audio:true,video:false});             this._stream=attendre navigator.mediaDevices.getDisplayMedia();             this._recorder=new MediaRecorder(this._stream,{mimeType:"video /webm;codecs=h264"});             this._recorder.ondataavailable=this.recorder_dataAvailableHandler.bind(this);         },









    







        recorder_dataAvailableHandler(e){             console.log(e);             this.currentWebmData=e.data ;         },         btnRecordClicked(){             this.recording=true ;             this.paused=false ;             this._recorder.start();         },         btnPauseClicked(){             this.paused=true ;             this._recorder.pause();         },         btnResumeClicked(){             this.paused=false ;             this._recorder.resume();         },         btnStopClicked(){             this.recording=false ;             this._recorder.stop();



















        },
        btnPlayClicked(){             this.$refs.player.src=URL.createObjectURL(this.currentWebmData);}     } });



Quatrièmement, l'effet

1. Sélectionnez la plage à enregistrerfiligrane, type_d3F5LXplbmhlaQ, shadow_50, text_Q1NETkDlsI_nmq7njKo, size_20, color_FFFFFF, t_70, g_se, x_16

 2. Vous pouvez cliquer pour commencer l'enregistrement

filigrane, type_d3F5LXplbmhlaQ, shadow_50, text_Q1NETkDlsI_nmq7njKo, size_20, color_FFFFFF, t_70, g_se, x_16

 

Je suppose que tu aimes

Origine blog.csdn.net/m0_56233309/article/details/124133560
conseillé
Classement