Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Obtain the media playback time from a media application

by Retired ‎02-16-2010 02:58 PM - edited ‎09-16-2010 03:27 PM (1,460 Views)



This article applies to the following:


  • BlackBerry® smartphones based on Java ® technology running BlackBerry® Device Software 4.0 and later



BlackBerry smartphone applications that play audio or video files may need to display the current media playback time. The media time can be obtained from the Player object by calling the getMediaTime( ) method as demonstrated in the following example:


Note: The getMediaTime( ) method returns TIME_UNKNOWN if the time cannot be determined.



import javax.microedition.media.*;
import javax.microedition.media.control.*;

private void play() {

Player player = null;

try {
String url = "file:///store/user/user/music/song.mp3";
player = Manager.createPlayer(url);

if (player != null) {

} catch (Exception e) {

class MediaTimeUpdater {

public void update(Player player) {

long time = player.getMediaTime(); // in microseconds



Users Online
Currently online: 17 members 494 guests
Please welcome our newest community members: