Make screen recorder with html css javascript | screen recorder javascript

Make screen recorder with html css javascript | screen recorder  javascript

Make screen recorder with html css javascript | screen recorder  javascript


 Welcome🎉 to Code With Random blog. In this blog, we learn that how we create a screen recorder app. We use HTML & javascript for this screen recorder. Hope you enjoy our blog so let's start with a basic HTML structure for a screen recorder.

HTML code 

 <!DOCTYPE html>  
 <html>  
  <head>  
   <title>Parcel Sandbox</title>  
   <meta charset="UTF-8" />  
  </head>  
  <body>  
   <video class="video" width="600px" controls></video>  
   <button class="record-btn">record</button>  
   <script src="./index.js"></script>  
  </body>  
 </html>  
There is all HTML code for the screen recorder app. Now, you can see output without CSS, then we write javascript for the screen recorder.
output
Make screen recorder with html css javascript | screen recorder  javascript

Now add javascript for functionality.

Javascript code 

 let btn = document.querySelector(".record-btn")  
 btn.addEventListener("click", async function () {  
  let stream = await navigator.mediaDevices.getDisplayMedia({  
   video: true  
  })  
  //needed for better browser support  
  const mime = MediaRecorder.isTypeSupported("video/webm; codecs=vp9")   
        ? "video/webm; codecs=vp9"   
        : "video/webm"  
   let mediaRecorder = new MediaRecorder(stream, {  
     mimeType: mime  
   })  
   let chunks = []  
   mediaRecorder.addEventListener('dataavailable', function(e) {  
     chunks.push(e.data)  
   })  
   mediaRecorder.addEventListener('stop', function(){  
    let blob = new Blob(chunks, {  
      type: chunks[0].type  
    })  
    let url = URL.createObjectURL(blob)  
    let video = document.querySelector("video")  
    video.src = url  
    let a = document.createElement('a')  
    a.href = url  
    a.download = 'video.webm'  
    a.click()  
  })  
   //we have to start the recorder manually  
   mediaRecorder.start()  
 })  
Final output


Make screen recorder with html css javascript | screen recorder  javascript

Make screen recorder with html css javascript | screen recorder  javascript

Now we have completed our javascript section,  Here is our updated output with javascriptHope you like the screen recorder. you can see output video and project screenshots. See our other blogs and gain knowledge in front-end development. Thank you 🙏💕

credit - yt channel AngleBrace

In this post, we learn how to create an screen recorder  using simple HTML & CSS and javascript. If we made a mistake or any confusion, please drop a comment to reply or help you in easy learning.

Written by - Code With Random/Anki 

Post a Comment

Previous Post Next Post