mercredi 21 janvier 2015

How can I read an audio stream stored in a bean on the fly from a richfaces page with mediaOutput?

Here is the code:



<a4j:mediaOutput element="object" cacheable="false" id="audio"
createContent="#{myBean.play}"
mimeType="audio" />


Bean:



public void play(OutputStream stream, Object data) throws Exception {
byte[] soundData = audioCaptcha.getChallenge().asByteArray();
stream.write(soundData);
}


Right now, I have a little grey div appearing in my page with the following message: "A plugin is needed to display this content".


Now, if I change the mimeType from "audio" to "audio/mpeg", I get the following error message in the grey div: "Video can't be played because the file is corrupt.".


Am I missing something? Or is there another way to achieve this?


Aucun commentaire:

Enregistrer un commentaire