It's a little tricky and IDK how experienced you are with multi-threading.
First off, I would try to use an MVC pattern. You've got the basics of your View portion set up. For the Model, perhaps an enum
class makes sense for each number of the phone number, where each enum
is associated with an ID, a String
for display and an associated Clip
(preloaded) or .wav file address (if using SourceDataLine
), and maybe a play method.
Then, a critical Control
capability is the playback of the phone number, in series, probably within its own thread so that you aren't dead in the water waiting for the sounds to finish playing.
I'd make this controller a class, and have it implement a LineListener
and have it respond to Line.EventType.STOP
(probably just set a state flag/boolean for a loosely coupled approach) as a way to manage the sequencing and timing of the individual Clip
or SourceDataLine
plays. (@camickr mentions this in a comment)
I'd also launch the portion that executes the playing of the phone number in its own thread. It can be a private class within the controller class, and thus make reference to the parent class's implementation of the LineListener
to check for when to proceed for the "next" sound.
That's the basic floor-plan. There are some details to work out still, but hopefully this will help get you going.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…