php – View IP Camera Video

Question:

Gentlemen, I'm no PHP expert, I'm starting now, and would like a direction on how to display my IP Camera – P2P video

snapshot.php

<?php
    $img="http://usuario:senha@ipddns:portacamip/mjpeg.cgi?user=usuario&password=senha&channel=0&.mjpg"; 
    readfile($img); 
?> 

index.php

<img src="http://meudominio.com/snapshot.php" width="640" height="380" name="refresh">

<script language="JavaScript" type="text/javascript">     
    image = "http://meudominio.com/snapshot.php"
    function Start() {
    tmp = new Date();
    tmp = "?"+tmp.getTime()
    document.images["refresh"].src = image+tmp
    setTimeout("Start()", 300)
    }
    Start();       
</script>

What am I doing wrong? Could you explain to me please?

Thanks.

Answer:

I believe the problem is here:

setTimeout("Start()", 300)

setTimeout takes a function in the first parameter. Your case is executing the Start function (which, because it is in string form, is doing an eval ) and passing the function result to setTimeout .

The correct thing would be:

setTimeout(Start, 300)
Scroll to Top