gpt4 book ai didi

audio - Dart web audio noteOn 内部错误

转载 作者:行者123 更新时间:2023-12-02 22:33:48 26 4
gpt4 key购买 nike

我试图让 Dart 播放音频,但每次我尝试播放音频时都会出现以下错误:

Internal error: 'dart:_blink': error: line 248: native function 'AudioBufferSourceNode_noteOn_Callback_RESOLVER_STRING_1_double' (2 arguments) cannot be found
Native_AudioBufferSourceNode_noteOn_Callback(mthis, when) native "AudioBufferSourceNode_noteOn_Callback_RESOLVER_STRING_1_double";

这是我的音频课:

class Audio {

static List<Audio> _loadQueue = new List<Audio>();

String _url;
bool loaded = false;
AudioBufferSourceNode _source;

Audio(this._url) {
if (audioContext == null) {
_loadQueue.add(this);
}
else {
load();
}
}

void load() {
print("Loading sound: " + _url);
HttpRequest req = new HttpRequest();
req.open("GET", _url);
req.responseType = "arraybuffer";
req.onLoad.listen((e) {
_source = audioContext.createBufferSource();
print("Found sound: " + _url + ". Decoding...");
audioContext.decodeAudioData(req.response).then((buffer) {
_source.buffer = buffer;
_source.connectNode(gainNode);
_source.connectNode(audioContext.destination);
loaded = true;
});
});

req.send();
}

void play() {
if (!loaded) { return; }
_source.noteOn(0);
}

void stop() {
if (!loaded) return;
_source.noteOff(0);
}

static void loadAll() {

_loadQueue.forEach((e) {e.load();});
}
}

音频上下文和增益节点在另一个类中创建,如下所示:

audioContext = new AudioContext();
gainNode = audioContext.createGain();
gainNode.connectNode(audioContext.destination);

Audio.loadAll();

我不知道问题是什么,特别是因为它说它是内部的,并且它缺少参数,但是 noteOn 函数只接受一个参数。

最佳答案

关于audio - Dart web audio noteOn 内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25434742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com