I have my webcam working in a WP page. My script is based on one that came with Webcam32, and actually pulls the image from the camera rather than from the server, but it should work well enough.
My page contains this:
<script type="text/javascript" src="/path/cam.js"></script>
<img src="/path to image" class="centered" alt="This is me" id="imagename" width="320" height="240" />
<script type="text/javascript">initialImage();</script>
The script looks like this:
newImage = new Image();
function loadNewImage(){
uniq = new Date();
uniq = uniq.getTime();
document.images.imagename.src=newImage.src;
newImage.src="http://<path to your image>?"+uniq;
}
function initialImage(){
uniq = new Date();
uniq = uniq.getTime();
newImage.onload=loadNewImage;
newImage.src="http://<path to your image>?"+uniq;
}
function imageError()
{
image = document.images.imagename;
image.onload = "";
image.onerror = "";
startstop.disabled = true;
document.images.imagename.src = "http://<path to default image>";
}
This version loads the image as normal, then immediately tries to reload it. The odd stuff with the ?uniq forces the browser to fetch the image rather than taking it from the cache.
EDIT: This could be adapted to pause for a short time before refreshing, depending on how often your FTP process happens.
Wow, I’ll give that a shot, but to be honest I really have no clue how to implement that…
* After giving it a shot – it seemed to work for about 3 seconds and then nothing? I saw the clock caption commencing. Am I doing something wrong?
http://www.kyletompkins.com/wp/?page_id=60
This is what my .js looks like. Am I close?
newImage = new Image();
function loadNewImage(){
uniq = new Date();
uniq = uniq.getTime();
document.images.imagename.src=newImage.src;
newImage.src=”http://www.kyletompkins.com/wp/webcam/capture1.jpg?”+uniq;
}
function initialImage(){
uniq = new Date();
uniq = uniq.getTime();
newImage.onload=loadNewImage;
newImage.src=”http://www.kyletompkins.com/wp/webcam/capture1.jpg?”+uniq;
}
function imageError()
{
image = document.images.imagename;
image.onload = “”;
image.onerror = “”;
startstop.disabled = true;
document.images.lescam.src = “http://www.kyletompkins.com/wp/webcam/capture1.jpg?”;
}
Still no luck yet…
I’ll keep trying to tweak this, but does anyone else have anything for me to try?
Cheers.
kyletompkins.com
I’ll have a look at this later – I’ve got other people working, shouldn’t be a problem with yours.