Java Reference
In-Depth Information
In Listing 9-5 the first thing we do is create a SoundPlayer pointing at our sample song. The
SoundPlayer will then be passed to the other objects that require access to it. For example, in the Scene , a
SoundControl is created that uses the SoundPlayer . A SoundControl is a class that contains the Play/Pause
button as well as the seek track.
One instance of each of our three example effects is created as well as a CheckBox . For each effect the
visible attribute is bound to the selected attribute of each CheckBox . I noticed while creating this
example that CheckBox does not have an action function attribute in the same way Button does; I think
this is an oversight. It would be very handy. I will have to talk to somebody about that!
Controlling the Audio
Before we get into how each effect was created, let's take a look at SoundControl and see how it provides
a graphical interface into our SoundPlayer class. Listing 9-6 shows the source code.
Listing 9-6. SoundControl.fx
public class SoundControl extends AudioVisualization{
var playButton:Button;
init{
var background = Rectangle{
width: 400
height: 40
arcHeight: 10
arcWidth: 10
fill: grayGradient
opacity: .3
}
insert background into content;
playButton = Button{
translateX: 13
translateY: 8
action: buttonClicked;
text: "Play";
}
insert playButton into content;
var group = Group{
translateX: 80
translateY: 15
onMouseReleased:mouseReleased;
onMouseDragged:mouseDragged;
}
insert group into content;
var track = Rectangle{
width: 300
height: 8
Search WWH ::




Custom Search