MediaStreamAudioSourceNode.MediaStreamAudioSourceNode()
MediaStreamAudioSourceNode()
构造器创建一个新的 MediaStreamAudioSourceNode
对象实例。
语法
var myAudioSource = new MediaStreamAudioSourceNode(context, options);
参数
- context
- 一个用来使用node的音频环境
AudioContext
。 - options
MediaStreamAudioSourceOptions
,一个map对象,定义MediaStreamAudioSourceNode
的属性:mediaStream
: 需要使用的音频流
示例
// define variables
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// getUserMedia block - grab stream 获取音频流
// put it into a 把音频流放入 MediaStreamAudioSourceNode
if (navigator.mediaDevices.getUserMedia) {
console.log('new getUserMedia supported.');
navigator.mediaDevices.getUserMedia (
// constraints: audio and video for this app
{
audio: true,
video: false
}).then(function(stream) {
// Create a MediaStreamAudioSourceNode
var options = {
mediaStream : stream
}
var source = new MediaStreamAudioSourceNode(audioCtx, options);
source.connect(audioCtx.destination);
}).catch(function(err) {
console.log('The following gUM error occured: ' + err);
});
} else {
console.log('new getUserMedia not supported on your browser!');
}
规范
Specification | Status | Comment |
---|---|---|
Web Audio API MediaStreamAudioSourceNode |
Working Draft |
兼容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes) |
未实现 | 未实现 |
(Yes) |
未实现 |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|
Basic support | 未实现 | 未实现 | 未实现 | 未实现 | 未实现 | (Yes) |