4 Replies Latest reply on May 25, 2011 5:05 PM by Devin Wilson

    play WAV file with a4j:mediaoutput

    Mario Baracu Newbie

      I have a .wav file in my backing bean (byte[]). I have no problems showing images with mediaoutput, but i cant reproduce any sound :(

      Any example or recomendation ?

      thx.

        • 2. Re: play WAV file with a4j:mediaoutput
          Mario Baracu Newbie

          hi nbelaevski,

          xhtml

          <a4j:mediaOutput element="object" session="true" createContent="#{SampleManager.play}" value="#{Sample.sample.file}"
          cacheable="false" width="300"/>


          SampleManager backing bean
          public synchronized void play(OutputStream stream, Object object) throws IOException {
           stream.write((byte[])object);
           }


          Sample persistence (called from value="#{Sample.sample.file}")
          public byte[] getFile() {
           return file;
           }


          im not sure if im doing the right thing with this " value="#{Sample.sample.file}" " on the a4j:mediaoutput tag. And the play method from my backing bean never been called.

          thanks for reply.

          • 3. Re: play WAV file with a4j:mediaoutput
            Mario Baracu Newbie

            forget the last codes.

            Now it works fine in Firefox, but in IE never calls the play method.

            xhtml:

            <a4j:mediaOutput session="true" element="object" mimeType="audio/x-wav" createContent="#{SampleManager.play}" value="#{SampleManager.file.name}" cacheable="false" width="300"/>
            
            

            i think the "value" isn't necesary in my case...

            SampleManager:
            public synchronized void play (OutputStream stream, Object object) throws IOException {
             SessionLogger.getInstance().STDLOG("SampleManager.paint()");
             stream.write(this.getFile().getData());
             stream.flush();
             stream.close();
             }
            
            


            this.getFile().getData() returns the .wav in byte[].

            IE8 & Firefox 3.0.12
            Richfaces 3.2.2GA


            • 4. Re: play WAV file with a4j:mediaoutput
              Devin Wilson Newbie

              The same thing is happening to me!!  Did you ever figure this out?  Thanks!