cordova-plugin-audioinput
cordova-plugin-audioinput copied to clipboard
Add getAudioMediaStream() function returning MediaStream
Some apps may need a MediaStream instead of an AudioNode or raw audio data.
It should therefore be possible to also get a MediaStream from the audioinput.
Should be implemented by returning the stream
from a MediaStreamAudioDestinationNode.
This would enable you to do stuff like this:
var chunks = [];
audioinput.start({streamToWebAudio: true}); // Start the capture
var stream = audioinput.getAudioMediaStream(); // Create/get a stream destination
var mediaRecorder = new MediaRecorder(stream); // Create a MediaRecorder
mediaRecorder.ondataavailable = function(evt) {
chunks.push(evt.data); // push each chunk (blobs) in an array
};
mediaRecorder.onstop = function(evt) {
var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' }); // Create a blob
document.querySelector("audio").src = URL.createObjectURL(blob); // <audio controls></audio>
};
Reminder: MediaStream and CreateMediaStreamDestination isn't available in the iOS WebViews, the change should take this into account. Maybe using polyfills on platforms where these where they aren't available so that getAudioMediaStream returns an object implementing the major functionality that MediaStream normally offers would be a good approach?
Hi i want implement this plugin in my cordova app. I want implement this in webRTC conection, but ios not have getUserMedia() function. Please you can me help ?
Yes, the missing getUserMedia in the iOS webviews is one of the reasons that this plugin exists, but it isn't currently a complete implementation of getUserMedia (for example only audio input is supported).
But luckily there already exists a cordova plugin for using WebRTC on iOS: https://github.com/BasqueVoIPMafia/cordova-plugin-iosrtc
I would recommend you to look into that plugin instead.