0

I have starting time of each sentence spoken in the audio. I can get the current time of audio using MediaPlayer.getCurrentPosition(). What i want to know is: What class or interface should i use that could monitor audio time contineuously and when it reaches at certain time (my given time) i could read next text and update on TextView.

My Audio files are so long (in MBs) and will be played from sdcard..

Can i use Android.AudioTrack class in static mode, (i am not sure it can be used but read documentation and AudioTrack object size or its buffer size depends upon available memory) Can MediaPlayer can work this out or some other interface/class etc or some sort of threading..

Please help me with possible idea(s).

ps: i am new to android but crazzzyy about it..

Note [using MediaPlayer.setOnCompletionListener(..) in can do it at the end of the audio file but as i said i want to to it on certain playback time.]

Tahir Jilani
  • 200
  • 1
  • 17

1 Answers1

0

The downside of AudioTrack is that you need to have decoded audio file (i.e. LPCM data). If your audio files are not in lpcm format (which I doubt they are), than you'll need to somehow decode the data yourself. But tracking progress in this case is an easy task.

But if you're ok with precision times around 200ms, you can try using Handler based timer and check current state of MediaPlayer in that timer. This way you won't need to decode data yourself.

The example Handler based timer: Repeat a task with a time delay?.

Community
  • 1
  • 1
inazaruk
  • 74,247
  • 24
  • 188
  • 156