Skip to main content

progress bar

2 replies [Last post]
maciejka79
Offline
Joined: 2008-02-07
Points: 0

Hi
how to make progress bar during the movie??
i know how to calculate time, animate and etc, but what is the best way to loop it??

best
mac

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
maciejka79
Offline
Joined: 2008-02-07
Points: 0

no tips??

gent2k7
Offline
Joined: 2007-06-25
Points: 0

Hi maciejka79,

In ClassX [i](implements ControllerListener as you want to redefine cotnrollerupdate(ControllerEvent e)[/i] :

[b]getPlayer().setMediaTime(new Time(0)); [/b]with getPlayer() return an instance of Player
[b]getPlayer().start();[/b]

Here you can get the duration of the media (when the info is updated) :

[b]public void controllerUpdate(ControllerEvent event) {
if (event instanceof javax.media.DurationUpdateEvent) {
duration = ((DurationUpdateEvent) event).getDuration();
}[/b]

Or you can use :
[b]if (player != null) {
return player.getDuration().getSeconds();
} [/b]

But be aware that sometimes (e.g. streaming ) this piece of information won't be available as the player starts.

with duration instance of Time.

Then you can get the current timecode with an instance of MediaTimePositionControl such as:

[b] timePositionControl = (MediaTimePositionControl) (getPlayer().getControl("org.davic.media.MediaTimePositionControl"));[/b]

by using :

[b]public double getMediaTime() {
cur_time = timePositionControl.getMediaTimePosition();
return cur_time.getSeconds();
}[/b]

In the end, you know where you are, you know where you go (you may also know the duration without calling player.getDuration(), if you simply have the stream...), so you have %done = current/total.