7516e95066
BUG= Review URL: https://codereview.chromium.org//410863002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38488 260f80e4-7a28-3924-810f-c04153c831b5
52 lines
1.8 KiB
Plaintext
52 lines
1.8 KiB
Plaintext
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
part of web_audio;
|
|
|
|
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
|
$!MEMBERS
|
|
$if DART2JS
|
|
factory AudioContext() => JS('AudioContext',
|
|
'new (window.AudioContext || window.webkitAudioContext)()');
|
|
|
|
GainNode createGain() {
|
|
if (JS('bool', '#.createGain !== undefined', this)) {
|
|
return JS('GainNode', '#.createGain()', this);
|
|
} else {
|
|
return JS('GainNode', '#.createGainNode()', this);
|
|
}
|
|
}
|
|
|
|
ScriptProcessorNode createScriptProcessor(int bufferSize,
|
|
[int numberOfInputChannels, int numberOfOutputChannels]) {
|
|
var function = JS('=Object', '#.createScriptProcessor || '
|
|
'#.createJavaScriptNode', this, this);
|
|
if (numberOfOutputChannels != null) {
|
|
return JS('ScriptProcessorNode', '#.call(#, #, #, #)', function, this,
|
|
bufferSize, numberOfInputChannels, numberOfOutputChannels);
|
|
} else if (numberOfInputChannels != null) {
|
|
return JS('ScriptProcessorNode', '#.call(#, #, #)', function, this,
|
|
bufferSize, numberOfInputChannels);
|
|
} else {
|
|
return JS('ScriptProcessorNode', '#.call(#, #)', function, this,
|
|
bufferSize);
|
|
}
|
|
}
|
|
$endif
|
|
@DomName('AudioContext.decodeAudioData')
|
|
Future<AudioBuffer> decodeAudioData(ByteBuffer audioData) {
|
|
var completer = new Completer<AudioBuffer>();
|
|
_decodeAudioData(audioData,
|
|
(value) { completer.complete(value); },
|
|
(error) {
|
|
if (error == null) {
|
|
completer.completeError('');
|
|
} else {
|
|
completer.completeError(error);
|
|
}
|
|
});
|
|
return completer.future;
|
|
}
|
|
}
|