PDA

View Full Version : Webcam with on air off air button/gif



fraggit
06-12-2011, 02:15 PM
Hi all
Hope someone can help? I have a ftp webcam which i want to show if it's "on air" or "off air", if on air then they just click the button or picture to go to the webcam page. I've been mucking around with this code=


<IMG src="http://example/cam_1.jpg" width="320" height="240" border="0" name="refresha">
<input type="button" id="newtext" value="SCANNING">
<img src="http://example/tmp_cam_1.jpg"width="1" height="1" name="refreshz">
<script language="JavaScript" type="text/javascript">

a = "http://example/cam_1.jpg"
y = "http://example/tmp_cam_1.jpg"

size = 0

function GetImages()
{
tmp = new Date()
tmp = "?"+tmp.getTime()

document.images["refreshz"].src = a+tmp
size1 = document.images["refreshz"].height
offair = document.images["refreshz"].width

if (offair ==1) {document.getElementById("newtext").value = "CAM ON AIR"}
if (offair ==2) {document.getElementById("newtext").value = "CAM OFF AIR"}
if (offair ==2) {size = size1}

if (size == 0) {size = size1}

if (size != size1)
{size=size1

document.images["refresha"].src = a+tmp


}

setTimeout("GetImages()",10*1000)}

GetImages()

</script>


I use this code to refresh pictures when uploaded to my website.All I can get is the "off air" "on air" button to do is show "on air" regardless if the cam is on or off. Am I just barking up the wrong tree with this script? or is there another bit of code that would be better? Thanks if you can help.

Paul