我正在开发一个带有麦克风的无线电系统,系统管理员将对麦克风说话,音频将实时传送给用户。我是使用node.js的新手,我不知道如何使音频流从麦克风到用户.有谁可以帮我?
我有下面的问题,我有麦克风的声音被录制在一个blob中,我需要知道如何播放这个blob .
我没有代码只显示音频记录..。
<script>
function getByID(id) {
return document.getElementById(id);
}
var recordAudio = getByID('record-audio'),
stopRecordingAudio = getByID('stop-recording-audio');
var audio = getByID('audio');
var audioConstraints = {
audio: true,
video: false
};
</script>
<script>
var audioStream;
var recorder;
recordAudio.onclick = function() {
if (!audioStream)
navigator.getUserMedia(audioConstraints, function(stream) {
if (window.IsChrome) stream = new window.MediaStream(stream.getAudioTracks());
audioStream = stream;
audio.src = URL.createObjectURL(audioStream);
audio.muted = true;
audio.play();
// "audio" is a default type
recorder = window.RecordRTC(stream, {
type: 'audio'
});
recorder.startRecording();
}, function() {
});
else {
audio.src = URL.createObjectURL(audioStream);
audio.muted = true;
audio.play();
if (recorder) recorder.startRecording();
}
window.isAudio = true;
this.disabled = true;
stopRecordingAudio.disabled = false;
};
stopRecordingAudio.onclick = function() {
this.disabled = true;
recordAudio.disabled = false;
audio.src = '';
if (recorder)
recorder.stopRecording(function(url) {
audio.src = url;
audio.muted = false;
audio.play();
document.getElementById('audio-url-preview').innerHTML = '<a href="' + url + '" target="_blank">Recorded Audio URL</a>';
});
};
</script>发布于 2014-06-06 19:23:16
我不是专家,但我记得很少有关于在html5rocks上捕捉音频的文章。
http://updates.html5rocks.com/2012/01/Web-Audio-FAQ http://www.html5rocks.com/en/tutorials/getusermedia/intro/#toc-webaudio-api
您应该尝试在npm库中搜索。我认为它可能有一些流节点模块。(从核心node.js API开始开发非常困难,我也想不出来。)
还请看一下以下内容:
Node.js synchronized audio streaming between server and clients?
下面是用于发送二进制数据的节点模块(我认为它支持流blob):http://binaryjs.com/
希望这些能帮上忙!
https://stackoverflow.com/questions/24088868
复制相似问题