4 Replies Latest reply on Sep 1, 2009 2:53 AM by nimo22

    questions about rich:mediaOutput

    nimo22

      Hello,

      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?


        • 1. Re: questions about rich:mediaOutput
          nbelaevski

          Hi,

          1. a4j:mediaOutput just outputs HTML element that refers to dynamically generated content. That's application developer concern how to generate/where to take from media resource data.

          2. It is not possible to restrict user from downloading of media file. If session=false, then no session scope won't be accessible from content creation method. For cacheable resource content will be stored in application cache and served from there. Expires defines the time for which resource content is valid if cached.

          3. Probably there's a better solution - what is used to play sounds in browser?

          4. I have no objections for such split - please file in RFC into JIRA and it'll be implemented if it is very popular.

          P.S. There are special streaming protocols for media that can be more effective to serve sound data, then HTTP that is used in a4j:mediaOutput by default.

          • 2. Re: questions about rich:mediaOutput
            nimo22

            hello,

            thanks for your response:

            to 1:
            okay, got it.

            to 2:
            when setting this in web.xml,
            org.ajax4jsf.ENCRYPT_RESOURCE_DATA = true, would the downloaded data be encrypted ? So the User can download the file via a streaming-tool but the file is useless, as it s encrypted. Am I right?

            (By the way, Your explanation of 2 is really good and should be adapted to the ref-guide)

            to 3:

            Probably there's a better solution - what is used to play sounds in browser?


            I guess, flash is used for playing sounds in browser. Or the new HTML5-Tags , ? What would be a better solution? Do you have any tips or resources?

            to 4:

            I have created a issue:
            https://jira.jboss.org/jira/browse/RF-7780

            to P.S.:
            There are special streaming protocols for media that can be more effective to serve sound data, then HTTP


            So I should make use of rich:mediaOuput properties like "classid" and "codebase" to link to, for example, the windows media player or a flash player? Can you suggest a player, protocol?

            • 3. Re: questions about rich:mediaOutput
              nbelaevski

              2. There's data object passed as argument to "createContent" method. This object can be encrypted using cryptography, if the parameter you've mentioned, is switched on. Resource content data is not encrypted and transferred as is via the network.

              3. HTML 5 tags are still not supported by IE, so you'd better use Flash or just built-in browser functionality.

              I've no experience in streaming servers, so can't suggest any of them. You can start from here: http://en.wikipedia.org/wiki/Comparison_of_streaming_media_systems and ask Google for more information then.

              • 4. Re: questions about rich:mediaOutput
                nimo22

                 

                There are special streaming protocols for media that can be more effective to serve sound data, then HTTP that is used in a4j:mediaOutput by default.


                Would it be possible to send data of mediaOutput via ajax?

                something like:

                a4j:mediaOutput mode="ajax"


                The only thing is, that this has to be thread-enabled (such as the rich:progressBar). Imagine getting (hearing sound) data and do other actions on the site as well, while these data are transmitted via ajax.

                Would this be possible?