gwt graphics- how to play sound in step with the animation being shown on screen

35 views
Skip to first unread message

arvindikchari

unread,
Mar 5, 2012, 10:27:46 PM3/5/12
to gwt-gr...@googlegroups.com
Hello,

I am trying to create a simple animation of a spinning bottle. As the bottle spins, I would like to play a sound accompanying the actual spinning action...I thought I should use the gwt-voices library for this, but how do I play the mp3 as an accompaniment to the animation?

And I want to play 3-4 different mp3 files at different stages of the animation...How do I do this?

One more question related to my problem is how to load the mp3 at first, so that when the animation is playing, there should not be a lag for the system to download the mp3(the mp3 should start playing at exactly the same time as the animation is shown on screen).

Thanks,
Arvind.

Jovan Perovic

unread,
Mar 6, 2012, 4:23:27 AM3/6/12
to gwt-gr...@googlegroups.com
You should definitely create animation from scratch by extending GWT's native Animation class. That way you will have method 

void onUpdate(double progress)

where progress goes from 0.0 to 1.0, so you could start any operation whenever you'd like. Make sure you store either initial/end state or initial state and difference into Animation class as you'll set animated properties by yourself. For example:

void onUpdate(double progress){
     shape.setX( start.getX() + diff * progress )
}

As for the sound, I'm not sure if this library supports preloading. Best bet would be to look into library's wiki to find that out, but quick glance over it did not reveal anything about it.

Hope this helps...
Reply all
Reply to author
Forward
0 new messages