startPlay method

void startPlay(
  1. List<String> files, {
  2. dynamic stepTime = 400,
  3. dynamic loop = false,
})

开始播放音效序列

Implementation

void startPlay(List<String> files, {stepTime = 400, loop = false}) {
  if(files.length == 0){
    return;
  }
  count = 0;
  timer = Timer.periodic(Duration(milliseconds: stepTime), (t) {
    if (count == files.length) {
      if (loop) {
        count = 0;
        String file = files.elementAt(count);
        play(file);
      } else {
        timer!.cancel();
        timer = null;
      }
    } else {
      String file = files.elementAt(count);
      play(file);
    }
    count++;
  });
}