2 Replies Latest reply on Apr 20, 2011 5:36 AM by urska

    MediaOutput for displaying stream of byte[] images

    urska

      I would need some help. I am using mediaOutput with a4j:poll to keep reRendering new images, which are stored in streamedPic property of scenesHelper bean.

       

                                               <a4j:poll id="myPoll" interval="1" 
                                                       enabled="true"
                                                       reRender="pollUpdate"
                                                       ajaxSingle="true"/>
      
                                                 <h:panelGroup id="pollUpdate">                                 
      
                                                                 <a4j:mediaOutput ielement="img" rendered = "#{scenesBean.selectedFile.streamedPic!=null}"
                                                               cacheable="false"
                                                               session="true"
                                                               createContent="#{scenesBean.paintTest}"
                                                               mimeType="image/jpeg">
                                                                <f:param value="#{scenesBean.timeStamp}" name="time" />
                                                                </a4j:mediaOutput>
                                                   </h:panelGroup>
      
      

       

      According to the code, the images should be rerendered every millisecond. But, I get around 2 images per second. The variable streamedPic changes around 20 pic per second, so it must be the problem in mediaOutut or a4j:poll?

      Any clues, hints?

        • 1. MediaOutput for displaying stream of byte[] images
          ilya_shaikovsky

          that's not proper way to implement streaming. setting interval=1 for poll means that you will send ajax request every millisecond. but that request will be processed about 20-50 milliseconds in better case. And you should also consider that mediaoutput also uses assync requests to load it's data. so your server just overloaded with different requests using that code.

          • 2. MediaOutput for displaying stream of byte[] images
            urska

            So then I should not use any Ajax components here, but turn to JavaScript with setInterval or sth like that to refresh the component with image? Or is there some other library that would take care of automatic reloading (refreshing) of components or image containers?