questions about rich:mediaOutput
nimo22 Aug 28, 2009 4:56 AMHello,
I have a few questions about rich:mediaOutput:
Question 1:
I use rich:mediaOutput successfully to play audio-files.
Where lies the main difference of using rich:mediaOutput or java-sound-api ? Does rich:mediaOutput uses java-sound-api (or java media framework) to play sound files?
For example, with java sound api, to play sound, we have to use something like this:
.. DataLine.Info info = new DataLine.Info(Clip.class, a.getFormat()); Clip clip = (Clip) AudioSystem.getLine(info); ..
Question 2:
Is it possible for the user to download the data transmitted via mediaOutput? If so, how can I prevent that ? Should I use this:
in web.xml:
org.ajax4jsf.ENCRYPT_RESOURCE_DATA = true
in jsf:
<a4j:mediaOutput session="true" cacheable="false" action="#{myBean.myMediaOutput}".../>
Property "cacheable":
if I set this to false, would the playing be slower?
if I set this to true, would the download be able?
Would it be at least encrypted, when ENCRYPT_RESOURCE_DATA=true?
Property "expires":
[according to manual]
The attribute allows to manage caching and defines the period after which a resource is reloaded.
What type of value does expires expect, what is the preset?
Property "session":
[according to manual]
If "true", a session for an object generation is restored.
What is the real meaning for the session-property. I do not understand the usefulness of session-property.
Question 3:
I have a stop-button (a4j:commandButton) to stop playing the sound by mediaOutput. (The stop-button sets the rendered attribute of mediaOutput to false.)
This works but the expection occurs:
ClientAbortException: java.net.SocketException
Should I prevent that catching the error:
public synchronized void myMediaOutput(OutputStream s, Object o) throws Exception { ... try{ stream.write(a); } catch(java.net.SocketException cae) { stream.write(0); } stream.flush(); stream.close(); }
Or is there a better solution?
Question 4:
Would it be reasonable to split the tag rich:mediaOutput to the following:
[list=]
rich:mediaPlayer
rich:imageOutput
rich:documentOutput
and provide fitted properties for these new components? For example:
rich:mediaPlayer:
can have stop, rewind, forward buttons,..(with using of java media framework or java sound api)
(for example, look at http://www.longtailvideo.com/players/jw-flv-player/)
rich:imageOutput
scaling image, effects,..
rich:documentOutput (for pdf,...)
disposition,...
I guess, these new tags rich:mediaPlayer, rich:imageOutput and rich:documentOutput would extend the component suite of RichFaces in a sensefully manner. Don't you think so?