?
Solved

preload the next image to avoid flicker on my web cam page

Posted on 2005-02-28
6
Medium Priority
?
355 Views
Last Modified: 2006-11-17
Hi

I have a webcam page that is an asp page. the code is :
************************************************************************************************************************
<%@LANGUAGE="VBScript"%>
<HTML>
<HEAD>
<% response.write ("<META HTTP-EQUIV=""REFRESH"" CONTENT=""" & Session("TimeSet") & """>" ) %>
</HEAD>
<BODY>
<div align="center">
        <%
            select case session("CameraSet")
            case "Cam 01"
                  response.write ("<img BORDER=""1"" src=""http://111.111.111.111/image.cgi?resoloution=704x480"" width=""704"" height=""480"" alt=""Cam 01"">" )
            case "Cam 02"
                  response.write ("<img BORDER=""1"" src=""http://111.111.111.112/image.cgi?resoloution=704x480"" width=""704"" height=""480"" alt=""02"">" )
            case "Cam 03"
                  response.write ("<img BORDER=""1"" src=""http://111.111.111.113/image.cgi?resoloution=704x480"" width=""704"" height=""480"" alt=""03"">" )
            end select
      %>
</div>
</BODY>
</HTML>
*************************************************************************************************************************
this page is used with <iframe> in a parent page. the parent page sets the session variables, which are which camera to view(CameraSet) and what the refresh time is (TimeSet). Everything is working perfectly except everytime the page refreshes it flickers.

Now to the question:

Is it possible to preload the next image and then switch to that? I presume that if the next image is cached then the refreshing of the page would be instant and therfore no flicking.

Thanks in advance.
0
Comment
Question by:jclothier
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13418375
I'm not VBScript person, so I'll have to give it to you by Javascript. You could refresh the src attribute of your images. Here's a shot

<%@LANGUAGE="VBScript"%>
<HTML>
<HEAD>
<% response.write ("<META HTTP-EQUIV=""REFRESH"" CONTENT=""" & Session("TimeSet") & """>" ) %>
</HEAD>
<BODY>
<div align="center">
        <%
          select case session("CameraSet")
          case "Cam 01"
               response.write ("<img name='image1' BORDER=""1"" src=""http://111.111.111.111/image.cgi?resoloution=704x480"" width=""704"" height=""480"" alt=""Cam 01"">" )
          case "Cam 02"
               response.write ("<img name='image2' BORDER=""1"" src=""http://111.111.111.112/image.cgi?resoloution=704x480"" width=""704"" height=""480"" alt=""02"">" )
          case "Cam 03"
               response.write ("<img name='image3' BORDER=""1"" src=""http://111.111.111.113/image.cgi?resoloution=704x480"" width=""704"" height=""480"" alt=""03"">" )
          end select
     %>
</div>
<script type="text/javascript">
var seconds = 30 * 1000; // 30 seconds

function reloadImages(){
    self.image1.src = "http://111.111.111.111/image.cgi?resoloution=704x480&random="+Math.random();
    self.image2.src = "http://111.111.111.112/image.cgi?resoloution=704x480&random="+Math.random();
    self.image3.src = "http://111.111.111.113/image.cgi?resoloution=704x480&random="+Math.random();
    setTimeout('reloadImages()',seconds);
}

setTimeout('reloadImages()',seconds);

</script>
</BODY>
</HTML>
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13418380
I forgot to remove

<% response.write ("<META HTTP-EQUIV=""REFRESH"" CONTENT=""" & Session("TimeSet") & """>" ) %>

It should not be a part of my code. You modify the interval between each refresh here

var seconds = 30 * 1000; // 30 seconds

 
0
 

Author Comment

by:jclothier
ID: 13418558
To Batalf

That works great, one thing though. how do I get my "session(TimeSet)" variable into "var seconds = 30 * 1000; // 30 seconds"
0
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
LVL 32

Accepted Solution

by:
Batalf earned 2000 total points
ID: 13418575
What's the format of it? If it's seconds, you could probably do it like this:

instead of:

var seconds = 30 * 1000; // 30 seconds

use this:

<% response.write ("var seconds=" & Session("TimeSet") & "*1000;" ) %>
0
 

Author Comment

by:jclothier
ID: 13418626
Funny I'd tried that and it didn't work, tried it again and it works like a dream. Thanks for your help and a quick response.
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13418636
Glad I could help!

Thanks for the "A"

Batalf
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question