Skip to content

Instantly share code, notes, and snippets.

@anilkay
Created November 29, 2019 20:21
Show Gist options
  • Save anilkay/a1200ad352162d9611163f6fecf57f42 to your computer and use it in GitHub Desktop.
Save anilkay/a1200ad352162d9611163f6fecf57f42 to your computer and use it in GitHub Desktop.
<html>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<body>
<h1> It is worked </h1>
<p>Bir ve iki </p>
<div id="app">
<h1> {{message}} </h1>
<button v-on:click="start">Start</button>
<button v-on:click="stop">Stop</button>
<button v-on:click="getRecord">GetRecord</button>
<a href="#" id="dow">AudioURL</a>
</div>
</body>
<script>
//Chrome'da çalışmaktadır.
let elo=new Vue({
el:"#app",
data:{
message:"mesaj",
medyaRecorder:null,
permission:null,
audiourl:""
},
mounted(){
let chunks=[];
navigator.mediaDevices.getUserMedia({ audio: true ,video:true})
.then(stream=>{
this.medyaRecorder=new MediaRecorder(stream,{type:"video/webm"});
this.medyaRecorder.addEventListener("dataavailable",event=>{
chunks.push(event.data);
});
this.medyaRecorder.onstop=function(ev){
console.log("On Stop Metodu Başladı");
let blob=new Blob(chunks);
let audiourl=window.URL.createObjectURL(blob);
console.log("On Stop Metodu Bitmek üzere");
const a = document.getElementById("dow"); //Binding niyeyse olmadı.
this.audiourl=audiourl;
a.href=audiourl
a.download="audio.webm"
console.log("Audiourl: "+audiourl)
}
});
},
methods:{
start:function(event){
this.medyaRecorder.start();
},
stop:function(event){
this.medyaRecorder.stop();
},
getRecord:function(event){
console.log("Autopilot");
alert(this.audiourl);
}
}
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment