Jump to content

Loading Image or Flash Movie depending on Connection Speed?


brent123456

Recommended Posts

I want to load and image if they have dial-up or a flash movie if they have high speed. Is there anyway I can do this when the user comes to the page for the first time?

 

I found the script below that another user had posted but I am not sure if that would work for checking dial-up vs high speed?

 

 

http://www.phpfreaks.com/forums/index.php/topic,155661.0.html

 

Thanks

you can't perfectly detect a users connection speed, but basically you have to have a link that will say "high speed" or "slow speed"

and it looks like

<a href="setspeed.php?speed=1">High Speed</a>
<a href="setspeed.php?speed=0">Slow Speed</a>

 

and setspeed.php does

<?php
session_start();
$_SESSION['speed'] = $_GET['speed'];
if($_SESSSION['speed'] != 1 || $_SESSION['speed'] != 0){
#Default set
$_SESSION['speed'] = 1;
die(header("location: Somepage.php"));
?>

 

then anytime you go load a file you do a check such as

<?php
if($_SESSION['speed'] == 1){
#load high speed graphics
}
else{
#load slow speed graphics
}
?>

 

java/javascript is the only method you will get for detecting the current data transfer speeds - I would sggest you serve an image by defaul and use javascript to replace that with a movie if the detected transfer rate is sufficient.

java/javascript is the only method you will get for detecting the current data transfer speeds - I would sggest you serve an image by defaul and use javascript to replace that with a movie if the detected transfer rate is sufficient.

 

So, would it be possible to set a variable with javascript? so the speed is detected in javascript and the process is the same in PHP?

no - php can't do anything for you here apart from set a javascript variable with the path of the movie file.

 

Transfer speed can only be detected client side NOT server side...

 

Once the detection is complete if the lower threshold for you movie is exceeded then you can replace teh html of the parent element of teh img tag awith an object tag for the movie...

you really shouldn't  "predict" the client's speed let them say what they want cause high/low res is more a preference thing vs a client's speed.  You can take the javascript result of "speed" and use ajax to push it in to the session variable, but I still think its a client's choice

its no big deal cooldude...

 

its essentially just the reverse of plugin detection - you put an image inside an object tag of a swf file - if flash is available then the swf plays if not user sees image...

 

I actuallythink that what is being asked here is a legitamate exercise in imporving user experience - something java/javascript shoudl be used for...

Does anyone have a link to an example link of how to use Javascript to detect the speed? This is not for an intro page it is for the main index page of my site. I have a small movie that has pictures and updates that loads when you first come to the main page of the site. Basically I don't want it to load for dial-up users. The link idea would work for an intro page but for my main index page it would already be loading by the time the user clicks the "High Speed" or "Low Speed" links.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.