kotlin-coroutines - Coroutine - Head First Kotlin(鼓机)中的引用代码
问题描述
嗨我想知道为什么当我注释掉声音文件时只播放一次
Thread.sleep(100 * (part.length + 1L))
从下面的代码
fun main() {
playBeats("x-x-x-x-x-x-", "toms.aiff")
}
fun playBeats(beats: String, file: String) {
val parts = beats.split("x")
println(parts)
var count = 0
for (part in parts) {
count += part.length + 1
if (part == "") {
playSound(file)
} else {
Thread.sleep(100 * (part.length + 1L))
if (count < beats.length) {
playSound(file)
}
}
}
}
解决方案
推荐阅读
- objective-c - Sanboxed 应用程序,通过引用包含文件?
- javascript - 继承的原型函数不是函数
- python - 如何为 Graphviz 中的每个节点添加标签?
- sockets - 如何使用 Golang 在 IP 标头中为 TCP 连接设置 ToS 字段
- windows - 使用批处理脚本在文本文件中的特定行号处插入文本
- tableau-api - 将 x 误差线添加到 tableau 中的散点图
- python-3.x - 如何使用 pm2 运行 python3 脚本
- javascript - Dom 操作与 ajax 请求上的 javascript 代码不同步?
- xamarin.forms - Signal R 大约需要 1 分钟才能连接到移动网络 Xamarin 形式的 Hub
- python - 百分位方法的Python numpy升级失败测试