Welcome!

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 BlackBerry Development Advisor ‎02-16-2010 02:58 PM - edited ‎09-16-2010 03:27 PM (1,412 Views)

Summary

 

This article applies to the following:

 

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

Details

 

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);
}
}
}

 

Contributors
Users Online
Currently online: 16 members 861 guests
Please welcome our newest community members: