Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
NewtownGuy
Posts: 22
Registered: ‎05-14-2009
My Device: Not Specified

Re: JavaScript runs once but won't continually update

Hi Abarber,

 

This is very helpful. Thank you !

 

Will this work with images that are dynamically loaded from the Internet ? I need an endless stream of new photographs (actually video frames) to get live video.

 

I'm a novice JavaScript programmer. Where do the images come from in your code ? Isn't it a 2-second delay in the checkImage and redirectImage ? Do these functions verify that a new image has been downloaded and decoded and is ready to be put on the screen, before starting to fetch the next one from the Internet ?

 

Will this code work on the 8330 ? (I made a typo when I said an 8830)

 

 

Please use plain text.
Developer
abarber
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: JavaScript runs once but won't continually update

Hello

 

yes it'll work on the 8330.

The images are loaded from the web, the first 8 images are requested after that they will be cached. But If I created more images it could go on forever just requesting with no caching.

 

The code waits for an image to load, then holds that image for 2 secs, then calls the next image.

 

 

Andrew

Please use plain text.
New Developer
NewtownGuy
Posts: 22
Registered: ‎05-14-2009
My Device: Not Specified

Re: JavaScript runs once but won't continually update

Hi Andrew,

 

 

I tested it on the 8330, and it does run. But there are several problems for what I need to do:

 

1) the screen is white and there's a little icon on the screen while it's loading each image

 

2) it fetches 8 images and then repeats them

 

 

 In my live video application, the frames never repeat because each image is new, so I need to download new images constantly, and I need to keep the previous image on the screen while the next one is being downloaded and prepared (decoding JPEG) for display.

 

I need as high a frame rate as possible to get the smoothest video. The frame rate will depend on the image size (320x240, 160x120, etc), file size (varies, 3 to 12 K-bytes), and download speed to the BB (varies, can be < 50 Kbps).

 

So I need to download image(i), decode it, and put it on the screen. While it's on the screen, I need to do the same with image(i+1), for i = 0 to forever.

 

 

 

Please use plain text.
Developer
abarber
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: JavaScript runs once but won't continually update

The script is to give you an idea of how to do it.

 

I think all the elements are there to do what you want to do.

 

I would thoroughly test the image.complete property though as I'm not sure it works 100% on older devices.

 

Andrew

 

Please use plain text.
New Developer
NewtownGuy
Posts: 22
Registered: ‎05-14-2009
My Device: Not Specified

Re: JavaScript runs once but won't continually update

My series of images is dynamic. The server chooses the most recent image out of an endless stream of images. There's no fixed array of images being sent. The series(i) of images being received by a given BB is just the sequence of images chosen for that particular handset by the server.

 

Please use plain text.
Developer
abarber
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: JavaScript runs once but won't continually update

Pretend if you will I am the server app creating the first 8 jpg images. Forget about what happens after 8.

 

Its just a list of images whether I create them or a server app.

Please use plain text.
New Developer
NewtownGuy
Posts: 22
Registered: ‎05-14-2009
My Device: Not Specified

Re: JavaScript runs once but won't continually update

Hi Andrew,

 

 

Can you add some comments that explain how your #4 code works ? I don't understand what the file names are, for example.

 

Thank you.

 

 

Please use plain text.
Guru I
Xandrex
Posts: 18,377
Registered: ‎07-29-2008
My Device: Z10 10.1.0.2312 / Playbook 2.1 / 8900 5.0
My Carrier: Vodafone France (SFR) & B&You

Re: JavaScript runs once but won't continually update


NewtownGuy wrote:
Why GIF instead of JPG ? For a given resolution, the file size of a GIF image is much larger than for a JPG because we're sending photographs (frames of video), not drawings.
using GIF, you have the ability to create an animation (= several images) inside a single GIF file.

http://en.wikipedia.org/wiki/Graphics_Interchange_Format

drawback is that it only allows 256 colors, meaning you have to make intelligent dithering or color choices.
second drawback is that you have to dynamically create on server-side a static animated GIF file containing your random images, that you will then push to the device. Overall, only one image is then sent to the browser.



The search box on top-right of this page is your true friend, and the public Knowledge Base too:
Please use plain text.
New Developer
NewtownGuy
Posts: 22
Registered: ‎05-14-2009
My Device: Not Specified

Re: JavaScript runs once but won't continually update

Hi Xandrex,

 

Thank you for your post on GIF. I can't use animated GIF because I'm putting live video on the screen. You can call it webcam live video, although it's not actually from a webcam. Live video raises many system-level issues, such as screen refresh, wireless download data rate, different frame and data rates for different users, latency, caching...

 

 

 

 

 

Please use plain text.
Developer
abarber
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: JavaScript runs once but won't continually update

I tested the image.complete property of the image and it is not working in earlier versions, its always true! So the previous method won't work.

 

Take a look at this script though.

 

It loads the next image before moving to the next page. No images are cached, so this is like a real time request call for all the images to the server for every page (which I think is what you're doing).

 

I don't think its ideal, as the only way to get the next image to load on the device is to actually display it in the older versions.

It looks funny for the intial frame but from then on it looks ok.

 

http://www.cesarcaballeroart.com/ViewerTest/ImgViewerOnLoadIdea.htm

 

Please use plain text.