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) {
player.realize();
player.start();
}
} catch (Exception e) {
}
class MediaTimeUpdater {
public void update(Player player) {
long time = player.getMediaTime(); // in microseconds
updateUI(time);
}
}
}