david.dehaven at oracle.com
Tue Sep 11 09:23:35 PDT 2012
> 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