DART AudioBufferSourceNode onEnded事件无法正常工作

时间:2014-12-06 10:38:29

标签: html5 dart web-audio dart-html

我正在尝试使用DART处理HTML5网络音频API但无法弄清楚为什么onEnded事件无效。

这是代码

import 'dart:html';
import 'dart:web_audio';
import 'dart:async';
import 'dart:typed_data';
//import 'package:web_ui/web_ui.dart';  
//import 'dart:io';

class AudioPlayer {
  AudioContext audioContext;

  AudioPlayer() {
     audioContext = new AudioContext();
     loadChunks();
  }

  loadChunks() {
    HttpRequest request = new HttpRequest();
    request.open("GET", "Say.mp3", async: true);
    request.responseType = "arraybuffer";
    request.onLoad.listen((e) {
       audioContext.decodeAudioData(request.response)
       .then((AudioBuffer audioBuffer) {
         AudioBufferSourceNode audioBufferSourceNode = audioContext.createBufferSource()
           ..buffer = audioBuffer
           ..connectNode(audioContext.destination)
           ..start(0)
           ..loop = false
           ..onEnded.listen((e) {
             print("TES");
           });
      });
    });
    request.send();
  }
}

代码有问题吗?请建议。

1 个答案:

答案 0 :(得分:0)

按照记录的方式尝试拼写:onended