Once a Media Player is prepared, call start to begin playback of the associated media:
mediaPlayer.start(); Use the stop and pause methods to stop or pause playback.
The Media Player also provides the getDuration method to find the length of the media being played, and getCurrentPosition to find the playback position. Use seekTo to jump to a specific position in the media as shown in Listing 11-7.
LISTING 11-7: Controlling playback
Available for download on Wrox.com mediaPlayer.start();
int pos = mediaPlayer.getCurrentPosition(); int duration = mediaPlayer.getDuration();
mediaPlayer.seekTo(pos + (duration-pos)/10);
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.