Skip to content

Commit

Permalink
fix an issue which would cause the wrong current time when the music …
Browse files Browse the repository at this point in the history
…player was playing.
  • Loading branch information
weiancheng committed Jan 17, 2018
1 parent c4ea967 commit 2f8ea08
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ class ExoPlayerWrapper(private val context: Context): IMusicPlayer {
override fun onTimelineChanged(timeline: Timeline?, manifest: Any?) {
if (exoPlayer.duration > 0) {
musicPlayer.listener?.onDurationChanged(exoPlayer.duration.div(1000).toInt())
}

musicPlayer.timer = PausableTimer(exoPlayer.duration, 1000)
musicPlayer.timer.onTick = { millisUntilFinished ->
musicPlayer.listener?.onCurrentTime(millisUntilFinished.div(1000).toInt())
}
musicPlayer.timer.onFinish = {
musicPlayer.listener?.onCurrentTime(0)
musicPlayer.timer = PausableTimer(exoPlayer.duration.minus(exoPlayer.currentPosition), 1000)
musicPlayer.timer.onTick = { millisUntilFinished ->
musicPlayer.listener?.onCurrentTime(millisUntilFinished.div(1000).toInt())
}
musicPlayer.timer.onFinish = {
musicPlayer.listener?.onCurrentTime(0)
}
musicPlayer.timer.start()
}
musicPlayer.timer.start()
}
}
}

0 comments on commit 2f8ea08

Please sign in to comment.