Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-02-28
6
Medium Priority
?
366 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
How do you create a user-centered user experience on your website? And what are some things you should consider in the process?
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

580 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