Topic: custom Webcam Widget

Hi,

I just got my chumby and I like it a lot!!!

So, one of the main reason to get one was that I saw that you guys had Webcam widgets....what I didn't realize was that they all just pull pre-defined sites ?

In't there one which can pull a jpg from a user-defined page ?

I have my own webcam on a static ip outside and would love to watch that camera...

Couldn't be there a widget which lets you add the url ? e.g. http://ip/webcam.jpg ? and maybe the interval to pull the image ? like 5/10/60 seconds ?

thanks for a reply...

Rene'

Re: custom Webcam Widget

I believe you will need to have crossdomain.xml on your server's root as a start. Also, are you exposing this to everybody or is it for your private feed? If the later, it should probably be a configuration parameter for the widget.

Re: custom Webcam Widget

hmm, guess only for myself...

not even sure, how I would do this..sorry I'm not a programmer...

I thought after getting my chumby connected and had the first widgets running I could just add a webcam widget from the section and change the settings to point to my webcam url...

I could get a file uploaded to the root of my site...

is there a sample file ? I could take and modify ?

Re: custom Webcam Widget

You don't need a crossdomain file to pull a JPEG from a site.

There is example Flash source for a webcam here.

Re: custom Webcam Widget

hmm, ok...

guess i'm don't understand ? how do i get this .fla file to work on my chumby ? e.g. into a channel ?

sorry, i understand that my lag of understanding how this work must be difficult for those who read my post...

I guess I have to...

1.) download the file
2.) edit the source url (do I need to buy adobe flahs for this ?)
3.) somehow run the custom file ?

Re: custom Webcam Widget

Yeah - the example is provided in "source" form, a Flash "FLA" file. One uses the Flash authoring tool to "compile" the FLA to a SWF file, then upload it to the server, which then feeds it to your chumby.

For something as simple as a webcam, you might be able to find an alternative "free" tool - for instance PHP with Ming - to create such a movie.

Re: custom Webcam Widget

so, lets say I "compile" the source file with my url...what does it mean "upload" the file to the server ? is there a link "howto" ?

Re: custom Webcam Widget

When you're logged into chumby.com, in the menu bar you'll see "widgets" item, and in there, a "upload a widget" item.

From there you'd fill in a brief form about your widget, upload the SWF for your widget and a small JPEG that shows a thumbnail of what your widget looks like.

Once it's uploaded, you can then select it for use on your chumby.  If you like, you can nominate it for public use so other people can use it also.

Alternatively, there are several other ways for running a FLash movie on a chumby, mostly documented on the wiki here.

Re: custom Webcam Widget

I have a chumby on the way and wantt o use it as the "tv" for a night vision webcam. The question is - are there any existing webcams that can be "pointed to" by an existing widget - and what sort of frame rates are we seeing?

Re: custom Webcam Widget

I used the samplecam.fla to create a webcam widget; it's working fine in Flashplayer 8 and it's showing normally as it should be in the Virtual Chumby.

Nevertheless as soon as I play it in channel on the Chumby, it opens, and then shows a "frozen" frame. After a long time (a couple of minutes), it refreshes. What could be wrong?

Thanks in advance!

Re: custom Webcam Widget

can you post the line that contains the actual URL to the webcam?  Many people that have edited the file have forgotten to include the "now" parameter that defeats the cache.

12 (edited by Stro 2007-12-09 06:33:57)

Re: custom Webcam Widget

Code wrote:

url = "http://www.abbeyroad.com/webcam/crossing.jpg";
delay = 1000;

createEmptyMovieClip("image0",0); // create some initial empty images
createEmptyMovieClip("image1",1);
createEmptyMovieClip("image2",2);

index=0;

then = 0; // long, long ago....
this.onEnterFrame = function () {
    now = (new Date()).getTime(); // get current time in ms from the epoch
    if (now-then>delay) { // enough time elapsed since last image loaded?
        doLoadImage(); // yup, load image
        then = now; // and reset the last load time
    }
}

function doLoadImage() {
    var name0 = 'image'+(index%3);
    var name1 = 'image'+((index+1)%3);
    var name2 = 'image'+((index+2)%3);
    var m0 = eval(name0);
    var m1 = eval(name1);
    var m2 = eval(name2);
    m0.swapDepths(0); // rotate the clips
    m1.swapDepths(1);
    m2.removeMovieClip(); // throw away the oldest one
    createEmptyMovieClip(name2,2); // make a new one
    m2 = eval(name2);
    m2.loadMovie(url); // load image into it
    index = (index+1)%3;
}

I guess there might be another issue due to the fact the image is slightly bigger than 320 x240. (384x284)

Your help is much appreciated, I'm just starting to have a look into Flash!

Re: custom Webcam Widget

Please try changing the line:

m2.loadMovie(url); // load image into it

to:

m2.loadMovie(url+'&now='+(new Date()).getTime());

Re: custom Webcam Widget

I get the following continuous error whilst debugging it;

Error opening URL 'http://www.abbeyroad.com/webcam/crossin … 7046019513'

Re: custom Webcam Widget

Ugh - it appears to be a poorly configured server.

The problem here is that they're serving up a dynamic image as a static file without setting the HTTP Cache-Control header, which tells the client how long to cache the image before reloading it.  Without the header, the chumby will cache the image for 5 minutes - this is different behavior from the desktop Flash, which treats response without such a header as non-cacheable.

The purpose of the "now" parameter was to make each fetch appear to be a different URL, so that the chumby's caching mechanism would treat them as different images.  Apparently the server doesn't like that.

In the original example code, which used a feed from CamZone, the server was properly setting the header, which is why the "now=" stuff wasn't necessary.

Re: custom Webcam Widget

Is there a workaround possible?

Re: custom Webcam Widget

Not off the top of my head, but if I think of one, I'll post it.

Re: custom Webcam Widget

I tried it by adding the following;

var nRandom = 1 + Math.floor(Math.random() * 500);
url = ("http://www.abbeyroad.com/webcam/crossing.jpg" + "?random=" + nRandom);

Unfortunately no succes...

Re: custom Webcam Widget

Duane wrote:

Please try changing the line:

m2.loadMovie(url); // load image into it

to:

m2.loadMovie(url+'&now='+(new Date()).getTime());

I think you meant to put ?now, not &now.  ?&now would work too, but you generally have to have that question mark first.

Re: custom Webcam Widget

clappro33 wrote:

I think you meant to put ?now, not &now.  ?&now would work too, but you generally have to have that question mark first.

Sorry, you're right, I'm an idiot sad - most of the webcams I've written for have more complex URLs with parameters, and I just append one more - I neglected to notice that that the one being used was just an image until later, and didn't make the connection.

Not enough coffee I guess - a particularly inconvenient problem, since I don't drink coffee.

Re: custom Webcam Widget

Hmmm, I just tried:

m2.loadMovie(url+'?now='+(new Date()).getTime());

...and it seemed to work.

Re: custom Webcam Widget

That's it! Thanks a lot folks for the insight; the widget is uploaded and awaiting approval!