Are there a Play, Pause, Rewind, Fast Forward methods in Android?

Using MediaPlayer you can seek to different positions in the stream but this is different from playing fast forward (or fast rewind), also known as "trick play" in DVRs.

However, fast forward can probably implemented using seekTo like this:

  • Set a periodic timer (ie postDelayed or scheduleAtFixedRate), every 100 msecs.
  • In timer's Runnable, call seekTo with a value that is a factor representing the play rate you want.
    • So if you want 2x fast forward then after every 100 msec period you will seek to curr_pos + 100 msecs. This means 100 msecs have passed but now you are at prev_pos + 200 msecs.
    • Performing 4x means after every 100 msec period you seek to curr_pos + 300 msecs.

.

  • I just realized that seekTo probably seeks to the nearest reference or I-frame. So calling seekTo(curr_pos + 100) may not get to the precise spot you want.

I might be required to implement FF in a video player I am working on. If I get it working I'll update my answer here.


Yes there are. Look at the MediaPlayer class:

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

Tags:

Java

Android