Does Android have ways to play, pause, rewind, fast forward?

I am working on an Android application that allows the user to talk on the device. Then I want to save this and rewind part of it to play it again, maybe jump to another part of the audio, pause it, play, etc. Like a main tape player.

Are there any built-in APIs or methods or code to allow this? If not, where should I go?

Any help would be greatly appreciated.

+7
source share
3 answers

Yes there is. Take a look at the MediaPlayer class:

http://developer.android.com/reference/android/media/MediaPlayer.html

+3
source

Using MediaPlayer, you can search for different positions in the stream, but this is different from fast-forwarding (or fast-forwarding), also known as a β€œtrick” in the DVR.

However, fast forward can probably be implemented using seekTo as follows:

  • Set a periodic timer (i.e. postDelayed or scheduleAtFixedRate ), every 100 ms.
  • In the Runnable timer, call seekTo with a value that is a factor representing the desired playback speed.
    • So, if you want 2x fast forward, then every 100 ms you will look for curr_pos + 100 ms. This means that 100 ms has passed, but now you are in prev_pos + 200 ms.
    • Doing 4x means that every 100 ms you try to use curr_pos + 300 ms.

.

  • I just realized that seekTo is probably looking for the closest link or I-frame. Therefore, the call to seekTo (curr_pos + 100) may not get to the exact place you want.

I may need to implement FF in the player I'm working on. If I get his work, I will update my answer here.

+6
source

Use AudioRecorder to record data. Use the PCM format.

Then you can play it selectivelly through AudioTrack .

0
source

All Articles