jmartine_1026 at yahoo.com
Tue Sep 11 10:10:18 PDT 2012
Thanks David. Since the constructor is synchronous and I guess would exception out if it fails, then I do not see a need for the progress and error. I see that you own the jira now and can close it.
One of the issues I am having now is delayed audio when I call play(). Usually this happens on the first call to play() and randomly on subsequent. The problem lessens if I set priority to 1, but still it happens on the first call. I am trying to reproduce on test code. Sometimes the delay is a second or more. In my app the user can click on a button, the nodes on the screen change when the button is clicked. I filter for mouse_clicked and play the audio before the eventHandler catches the event and changes the screen. So I was hoping the audio would get a head start over the screen changes, but still the delay remains. I am not asking for a fix or anything but maybe some direction on where I should search...... BTW, I posted this question on OTN first before bringing up here.
From: David DeHaven <david.dehaven at oracle.com>
To: Jose Martinez <jmartine_1026 at yahoo.com>
Cc: openjfx mailing list <openjfx-dev at openjdk.java.net>
Sent: Tuesday, September 11, 2012 12:23 PM
Subject: Re: AudioClip progress
> Am I the only one that needs a progress and error indicator in the AudioClip? I'm wondering why its not there and makes me think I might be using the wrong. Was it not made to handle files with size greater than small?
The short answer: No, it's not intended for large files, for those use a MediaPlayer.
AudioClip is for short sound clips for sound effects and it pre-loads the clips into memory, so if you feed it a large file you'll be consuming that much more memory (and then some for each time you play it back). If you want something longer for say background music you should really use a MediaPlayer and you'll get load progress and a full state machine with error reporting. Clips are also loaded synchronously, they're available to play immediately after the constructor returns unlike MediaPlayers which may not play right away (especially for network resources). If you want to pre-load AudioClips or (ideally) not block the application thread while loading clips, offload the task to a background thread and load each clip sequentially. For the moment you'll have to do your own asset management...
We've discussed doing some form of asset/cache management for media in future versions, but haven't had the time to even draft any preliminary APIs yet. We're open to ideas and suggestions.
More information about the openjfx-dev