如何解决在Android Studio中播放连续的音频
怎么样,我需要播放5个随机音频,一个又一个...我已经解决了随机功能,但是我希望这5个音频之间有大约1秒的时间间隔,我可以使用这种形状的SLEEP:
//play the sounds consecutively
sonidoIndexA();
espera();
sonidoIndexB();
espera();
sonidoIndexC();
espera();
sonidoIndexD();
respuestaCorrecta = Integer.toString(indexA) + Integer.toString(indexB) +
Integer.toString(indexC) + Integer.toString(indexD);
System.out.println(respuestaCorrecta);
}
//Wait a certain time
private void espera() {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
但是SLEEP给我带来了一些与时间有关的问题,因为我希望在播放这些音频时禁用某些按钮,但是使用SLEEP只能在播放音频之前实现... SLEEP是否可以替代?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。