I wanted to implement an function that plays only the last 5 seconds of an Audiofile (wich is longer than 5 seconds). Does Mediaplayer somehow support that?
I know how to normally play an Audio file + I know how to get the duration of the file, but how do I set the Mediaplayer to play only the short part at the end? So that means playing from a specific timecode in the Audiofile.
One way to implement this would be to use MediaPlayer.getDuration()
method to get the audio file duration and then use the MediaPlayer.seetTo()
API to move to that position..
In your case you can try mediaPlayer.seekTo(mediaPlayer.getDuration()-(5*1000));
...