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

Link to comment
Share on other sites

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
}
?>

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.