Brothers i'm working on a Chat application on Laravel platform, In which i want to record Voice message through browser. I searched for 3rd part library but i failed. Or Is there any way to get audio input from mic, please do let me know. thanks
Asked
Active
Viewed 1,978 times
0
-
2The solution to this would probably be client-side, so not sure if php/laravel tags are appropriate. That being said, this may be a duplicate of [this question](http://stackoverflow.com/questions/27846392/access-microphone-from-a-browser-javascript). – Jeff Lambert Mar 16 '17 at 19:18
1 Answers
0
I've had a run with https://github.com/feross/simple-peer but I've not gotten to integrating it with laravel.
It's documentation on setting up video/voice was pretty clear to me as a start, but getting beyond that I'm not sure, this video is what helped me through it.
var SimplePeer = require('simple-peer')
// get video/voice stream
navigator.getUserMedia({ video: true, audio: true }, gotMedia, function () {})
function gotMedia (stream) {
var peer1 = new SimplePeer({ initiator: true, stream: stream })
var peer2 = new SimplePeer()
peer1.on('signal', function (data) {
peer2.signal(data)
})
peer2.on('signal', function (data) {
peer1.signal(data)
})
peer2.on('stream', function (stream) {
// got remote video stream, now let's show it in a video tag
var video = document.querySelector('video')
video.src = window.URL.createObjectURL(stream)
video.play()
})
}

Justin Reasoner
- 144
- 4