Syncing Progress of mediaplayer with ObjectAnimator

28 views Asked by At

I'm using the Library -> https://github.com/alxrm/audiowave-progressbar

My target is to play the song in the form of waveform

the problem im facing is when i click on play song started playing but the progress animation doesnt sync up with the player

code :--

 override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mediaPlayer = MediaPlayer.create(this, R.raw.chris);

val animation = ObjectAnimator.ofFloat(wave, "progress", 0F, 100F).apply {
  interpolator = LinearInterpolator()
  duration = 1000
}
play.setOnClickListener {
  inflateWave()
  mediaPlayer?.start();
  wave.setRawData(assets.open("chris.mp3").readBytes()) { animation?.start() }
}

list.setOnClickListener {
  startActivity(Intent(this, RecordListActivity::class.java))
}

simple.setOnClickListener {
  startActivity(Intent(this, AnotherActivity::class.java))
}


wave.onStartTracking = {
  Log.e("wave", "Started tracking from: $it")
}

wave.onStopTracking = {
  Log.e("wave", "Progress set: $it")
}
}

output which im getting is -> [enter image description here]1

the song keeps playing but progress bar ends before that need help

thanks in adavance

0

There are 0 answers