I have an image file (for example img.png) which is updated (overwritten) every 20-30ms using a java program.
Now, I want the client to be able to 'watch' the image as it changing (it will look like a video streaming).
I used Javascript to update the image every 20-30ms but it is not that efficient as it consumes a lot of processing power. I also tried to use Ajax and jQuery.
Any suggestions on how to improve the performance? Can I use a player like jwPlayer or Flow Player? Should I use something different and more efficient?
Thanks.
PS. I have already implemented it using JApplet but I would like to avoid that solution.
sounds like you just want a slideshow; there are super fast efficient slideshows in JavaScript, i'm lazy so here's the jQuery version:http://mathiasbynens.be/demo/slideshow if you're having performance issues using this, it's not because of the slideshow
You can update image using javascript timer (setTimeout) eg url
You can update image by appending a random string at the end.
function update(){
$('#image').attr('src', $('#image').attr('src')+'?'+Math.random());
}
setTimeout("update()",150);
..it consumes a lot of processing power
Note that 'processing power' is not the same as 'bandwidth'.
To save bandwidth, it would make more sense to assemble the images into a video at the server side, and stream the video to the client. Video compression formats generally save a lot of bytes over a series of images, because they can compress images taking into account similar parts of different frames.