-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecordJs.min.js
1 lines (1 loc) · 3.11 KB
/
RecordJs.min.js
1
function RecordJs_Init(e){let t=[],d='<video autoplay id="web-cam" class="screen-no-record" style="background: black;width: 700px;height: 400px;"> Votre navigateur ne support le format vid\xe9o </video><p class="mg-b1" id="message">'+e.Message.befor_html+'</p><div id="btn-group" class="row"><div class="col-3"><button id="start-rec" >'+e.Start_Btn.value+'</button></div><div class="col-3"><button id="stop-rec" class='+e.Stop_Btn.class+" disabled> "+e.Stop_Btn.value+'</button></div></div><div id=recodeVide_Download style="margin-top:30px"></div>',o='<video autoplay id="web-cam" class="screen-no-record" style="background: black;width: 700px;height: 400px;"> Votre navigateur ne support le format vid\xe9o </video><p class="mg-b1" id="message">'+e.Message.befor_html+'</p><div id="btn-group" class="row"><div class="col-4"><button id="start-rec" >'+e.Start_Btn.value+'</button></div><div class="col-4"><button id="stop-rec" class='+e.Stop_Btn.class+" disabled> "+e.Stop_Btn.value+'</button></div><div class="col-4"><form><input type="hidden" id="Url_video" name="url_record" value=""><button id="next-rec" class='+e.Next_Btn.class+" disabled> "+e.Next_Btn.value+'</button></from></div></div><div id=recodeVide_Download style="margin-top:30px"></div>';if(document.querySelector("#RecordJs")){document.querySelector("#RecordJs").innerHTML=e.Download?d:o;let r=document.querySelector("#start-rec"),a=document.querySelector("#stop-rec");if(r.setAttribute("class",e.Start_Btn.class),a.setAttribute("class",e.Stop_Btn.class),!1==e.Download){let s=document.querySelector("#next-rec");s.setAttribute("class",e.Next_Btn.class)}let l=document.getElementById("web-cam"),i={audio:!0,video:!0};r.onclick=function(){navigator.mediaDevices.getUserMedia(i).then(d=>{let o=new MediaRecorder(d);window.mediaStream=d,window.mediaRecorder=o,o.start(),o.ondataavailable=e=>{t.push(e.data)},o.onstop=()=>{let d=new Blob(t,{type:"video/mp4"});t=[];let r=document.createElement("video");r.controls=!0;let a=URL.createObjectURL(d);r.src=a;let s=document.createElement("br"),l=document.createElement("a");if(l.download="RecordJs",l.href=a,l.innerHTML="T\xe9l\xe9charger la vid\xe9o",!1==e.Download){let i=document.querySelector("#Url_video");i.setAttribute("value",a)}l.onclick=()=>{URL.revokeObjetURL(o)},e.Download&&document.getElementById("recodeVide_Download").append(r,s,l)},l.srcObject=d,document.getElementById("start-rec").setAttribute("disabled",""),document.getElementById("stop-rec").removeAttribute("disabled"),!1==e.Download&&document.getElementById("next-rec").setAttribute("disabled",""),document.getElementById("message").innerHTML=e.Message.in_html}).catch(t=>{alert(e.Message.erreur_text)})},a.onclick=function(){window.mediaRecorder.stop(),document.getElementById("stop-rec").setAttribute("disabled",""),document.getElementById("start-rec").removeAttribute("disabled"),window.mediaStream.getTracks().forEach(e=>{e.stop()}),document.getElementById("message").innerHTML=e.Message.after_html,!1==e.Download&&document.getElementById("next-rec").removeAttribute("disabled")}}else alert("RecordJS dont no work. Please, create <div> with id value is 'RecordJs' ( <div id='RecordJs'></div> )")}