Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Webcam script

  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Webcam script

    Hi all
    First post here. Hope someone can help.
    I have a webcam that is using ftp.
    I have a script that works for about 10 or less refreshes most of the time then stops.
    The page I have it uploading to is Here . The code is....
    [CODE]
    <body>
    <script type="text/javascript" language="JavaScript">
    newImage = new Image();

    function LoadNewImage()
    {
    var unique = new Date();
    document.images.webcam.src = newImage.src;
    newImage.src = "http://www.qsl.net/2d0drm/cam_1.jpg?time=" + unique.getTime();
    }

    function InitialImage()
    {
    var unique = new Date();
    newImage.onload = LoadNewImage;
    newImage.src = "http://www.qsl.net/2d0drm/cam_1.jpg?time=" + unique.getTime();
    document.images.webcam.onload="http://www.qsl.net/2d0drm/tmp_cam_1.jpg";
    }
    </script>

    <img src="http://www.qsl.net/2d0drm/cam_1.jpg" name="webcam" onload="InitialImage()" width="320" height="240">
    </body>
    [CODE]
    I wondered if someone could tell me why it does this? or even ammend any mistakes.
    I have tried other refresh scripts, but they seem to have refreshes where there are gaps, which is what i'm trying to avoid.
    I think it just goes out of sync with the uploading cam images.
    What I like about the script in the link above is(so I believe), it holds the last image until another uploads, so eliminating the gaps.

    Thanks if you can help

    Paul

  • #2
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anybody????

  • #3
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    328
    Thanks
    9
    Thanked 49 Times in 48 Posts
    Hi fraggit.
    Welcome...

    It probably stops because it has encountered error in image. Try this one:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    >
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
        <
    meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <
    title>New Page 1</title>
        
        <
    script type="text/javascript">
            
        function 
    LoadNewImage(){
            
    webcam.src newImage.src;
            var 
    unique = new Date();
            
    newImage.src "http://www.qsl.net/2d0drm/cam_1.jpg?time=" unique.getTime();
        }
            
        function 
    InitialImage(me){
            
    webcam me//NOTE THE SHOWN IMAGE ELEMENT
            
    webcam.onload null//ONLY EXECUTED ONCE, DISABLE THIS RIGHT AWAY.
            
            
    newImage.onload LoadNewImage;     //LOAD NEW IMAGE EITHER AFTER SUCCESSFUL LOAD,
            
    newImage.onerror LoadNewImage//OR EVEN AT ERROR.
            
            
    var unique = new Date(); //THE FIRST TRIGGER ON NEWIMAGE
            
    newImage.src "http://www.qsl.net/2d0drm/cam_1.jpg?time=" unique.getTime();
        }
        
        var 
    newImage = new Image(), webcam null;
            
        
    </script>
    </head>

    <body>
        <img src="http://www.qsl.net/2d0drm/cam_1.jpg" onload="InitialImage(this)" alt="" 
            width="320" height="240"/>
    </body>

    </html> 

  • #4
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi hdewantara

    Thanks for the reply and thanks for the welcome
    Also thanks for the explaination of the script you provided (how many thanks is that )

    It still shows no image sometimes, which I now know is down to an error.
    I could kick myself for not realising that

    Now, that "newImage.onerror" command has got me thinking.
    The ftp command goes like this
    FTP Thread Started
    >> Connected to qsl.net [Passive Mode]
    >> Change directory to / completed.
    >> File tmp_cam_1.jpg transfered.
    >> File cam_1.jpg deleted.
    >> Renamed tmp_cam_1.jpg to cam_1.jpg.
    >> Disconnected
    Do you think there is a way of incorporating the "tmp_cam_1.jpg" into the script as a holding frame if there is an error to negate the gap?
    Because I think "Renamed tmp_cam_1.jpg to cam_1.jpg" is where the error in the ftp image comes from (I am probably wrong).
    Or, is there a way with the script to hold the last image if it encounters an error.
    Sorry if this is a dumb question.
    As you've probably already gathered, I am a complete newbie, but willing to learn.

    All the best
    Paul

  • #5
    New to the CF scene
    Join Date
    Sep 2012
    Location
    Orebro, Sweden
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a similar problem on our webcam-portal we're working with.
    Is there a way to "come around" this?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •