raulraja
10/17/2018, 5:20 PMbindingCatch {
val songUrl = getSongUrlAsync().bind()
val musicPlayer = MediaPlayer.load(songUrl)
val totalTime = musicPlayer.getTotaltime()
val end = PublishSubject.create<Unit>()
Observable.interval(100, Milliseconds).takeUntil(end).bind()
val tick = bindIn(UI) { musicPlayer.getCurrentTime() }
val percent = (tick / totalTime * 100).toInt()
if (percent >= 100) {
end.onNext(Unit)
}
percent
}
The example above is in Observable
but the same would work with Coroutines, Flux, and most data types that Arrow supports.