Re: Help developing a "generic webcam" widget

Here's what I recommend - since each feed might have different conventions about where you might have to put the cache-defeating code, one might adopt some sort of substitution mechanism.


For instance, you could create a standard pattern, say "$NOW$" that is replaced by the current timestamp using a simply Actionscript trick:

url= url.split('$NOW$').join((new Date()).getTime());

Then the person would enter the url as something like:

http://my.camera.ip/someImage.php?someparameter=blah&now=$NOW$

This would handle the case where the 'now' parameter is both the only argument (requiring '?') and one of many (requiring '&').

Or, one can make some attempt to intelligently figure out by examining the URL entered to see which to use - to be save one would have to create a pretty complete URL parser.

27 (edited by ccolumbu 2007-12-21 12:13:49)

Re: Help developing a "generic webcam" widget

I am not sure I agree, if the URL already contains a ? then use & if not use ?, do you see any problems with my logic?
The main thing is you can count on the end user to behave badly, so it is not wise to depend on them to "add some string" to the end of the URL.
We need the code to do it for them.

Re: Help developing a "generic webcam" widget

I am not a programmer so I do not understand much of this, but JVC sent me this widget and it seems to be working fine for me. A customizable refresh setting would be kinda nice though.

-HuckFinn

29

Re: Help developing a "generic webcam" widget

Yeah Duane this is why I hadn't initially put the code in there. Since the widget takes a url string as the input I didn't want to manipulate it as doing so may cause the loading to fail. In keeping it simple I left this code out. If I do put it in there I would probably go the "?cachebuster="+new Date.getTime() route and put YMMV disclaimer that  "disabling caching may cause the URL to fail.

Re: Help developing a "generic webcam" widget

Hey jvc, could you send me the widget??

31

Re: Help developing a "generic webcam" widget

I updated the widget with a prevent caching option. you will have to visit the configuration as it's turned off by default for backwards compatibility

Here's the updated code:

var imageHolder:MovieClip = this.createEmptyMovieClip("mcImageHolder", this.getNextHighestDepth());
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(this);

function onLoadError (target_mc : MovieClip, errorCode : String, httpStatus : Number)
{
    trace("onLoadError "+arguments); 
}
function onLoadStart (target_mc : MovieClip)
{
    trace("onLoadStart "+arguments); 
}
function onLoadProgress (target_mc : MovieClip, loadedBytes : Number, totalBytes : Number)
{
    trace("onLoadProgress "+arguments); 
}
function onLoadComplete (target_mc : MovieClip, httpStatus : Number)
{
    trace("onLoadComplete "+arguments); 

}
function onLoadInit (target_mc : MovieClip)
{
        var pctToScale:Number;
        var orientation:String;
        if(target_mc._width>=target_mc._height)
        {
            //is Portrait
            orientation="Portrait";
            pctToScale = NIPO(320, target_mc._width);
        
        }else
        {
            orientation="landscape";    
            pctToScale = NIPO(240, target_mc._height);
        }
        trace("pctToScale");
        target_mc._xscale=target_mc._yscale=pctToScale;
        target_mc._x = (320-target_mc._width)/2;
        target_mc._y = (240-target_mc._height)/2;
}

function NIPO (N:Number, V:Number):Number
{
    var a:Number = N / V;
    var P:Number = a * 100;
    return P;
}
this.stop();
var imagePath:String;


if(_root.IMAGE_URL != undefined)
{
    imagePath = _root.IMAGE_URL;
}
else
{
    imagePath = "http://mindlessabstraction.com/NoImage.jpg";
}
var preventCaching:Boolean = false;
if(_root.PREVENT_CACHING =="true")
{
    preventCaching = true;
}
if(preventCaching)
{
    if(imagePath.indexOf("?") == -1)
    {
        imagePath+="?cachebuster="+new Date().getTime();
    }else
    {
        imagePath+="&cachebuster="+new Date().getTime();
    }
}
mcl.loadClip(imagePath, imageHolder);
trace("imagePath : "+imagePath);

Re: Help developing a "generic webcam" widget

Ed S wrote:
ih8gates wrote:

It'd be a pretty easy task to munge the webcam example to take a URL in the config screen

That's the thing: it's not.  First, FlashDevelop seems to be Windows-only and some of us are Linux-only (as in: no MS products in our home).  OpenLaszlo should work, but if I understand correctly it's a completely different language (not .fla).

The point is, if there are two options:

  a) Download and install some new flash-building software; learn a new language; write and debug a custom tool that views ONE and only one webcam; test it; upload to chumby.com; or

  b) Click to install a generic webcam widget; click configure; enter a URL

...it seems to me that (b) is an option worth pursuing.

Yes, I have to agree with this one,   B would be excellent. I am definitely not a programmer, I hacked my way through some open source software that I saw on this site to do the webcam that I did.  Could not figure out how to add a banner or make it auto update. 

I would not open the sample .FLA widget with the software, or I could not figure out how to do it..  Make it simple...

Re: Help developing a "generic webcam" widget

JVC, have you released this updated widget to the website? I am using your original widget and it is working fine. I would like to have several instances of this widget running for various web images. Thanks for all of the work and effort. I really appreciate it.


jvc wrote:

I updated the widget with a prevent caching option. you will have to visit the configuration as it's turned off by default for backwards compatibility.

-HuckFinn

34

Re: Help developing a "generic webcam" widget

yeah - if you have the widget you have the updated version

Re: Help developing a "generic webcam" widget

I still do not see this is the lab yet, JVC have you heard back from Chumby support?

36

Re: Help developing a "generic webcam" widget

I haven't but I also haven't been pushing it. If you want the widget just add jvcleave as a chum and I can send it over

Re: Help developing a "generic webcam" widget

Hi jvc,
can you send the webcam widget to me?
thanks
John (widiver)

Re: Help developing a "generic webcam" widget

Jvc,

I have a request with your widget, which hopefully is pretty simple if you decide to implement it. Could you change the default screen color of your widget to a darker color? Basically just before the webcam image loads the screen is white. In a dark room this is pretty distracting. If you could make this user configurable that may make more users happy, but for me any dark color is fine.

Thanks

-HuckFinn

39 (edited by huckfinn 2008-01-07 15:41:42)

Re: Help developing a "generic webcam" widget

Chumby Support -

Can you please release this widget to the labs? JVC has sent me this widget and it is working fine for me, but I have no way to move or copy it to other channels. It seems that you can not "send" a widget that was sent to you. I would like to have several instances of this widget running to view different images in the same and other channels.

Thanks

-HuckFinn

Re: Help developing a "generic webcam" widget

It's now available from the Chumby Labs list. Working great! I already have 4 running with images from weather.com, weather.gov and my Weatherbug weathercam at my office. Thanks, JVC!

- Rich

Dallas TX
Chumby1 Birthday 11/1/07

Re: Help developing a "generic webcam" widget

Thanks for a great widget, JVC!