Page 1 of 5

Detecting Broadband?

Posted: Tue Dec 26, 2006 7:03 pm
by ineededasn
I was thinking about putting video on my Website, but I don't want to annoy dial-up viewers with large files loading when they visit my site. I was wondering if there was any way to detect a users connection speed so it wouldn't display the videos if their speed were too low. If anyone knows how this could be done or has any suggestions, I'd love to hear them.

Posted: Tue Dec 26, 2006 7:09 pm
by jayshields
You can't. Just put a form on there asking them if they have a high-speed connection or not.

Posted: Wed Dec 27, 2006 12:25 am
by neel_basu
But You Can detect The Speed By Which You Can Decide What To Do Next
=====================================================

Code: Select all

<?php
/* SURFING SPEED DETECTER SCRIPT */
function tmdf($a, $b)
  {
    list($a_dec, $a_sec) = explode(" ", $a);
    list($b_dec, $b_sec) = explode(" ", $b);
    return $b_sec - $a_sec + $b_dec - $a_dec;
  }
function tstspd($test_size)
  {
    flush();
    $start_time = microtime();
    //You Can Change The $comment As You Wish
    $comment = "<!--N-->";
    $len = strlen($comment);
    for($i = 0; $i < $test_size; $i += $len)
      {
        echo $comment;
      }
    flush();
    $duration = tmdf($start_time, microtime());
    if($duration != 0)
      {
        return $test_size / $duration / 1024;
      }
    else
      {
        return log(0);
      }
  }
$speed = tstspd(1024);
//More Accrecy Block Started
if($speed > 50)
  {
    $speed = tstspd(10240);
    if($speed > 500)
      {
        $speed = tstspd(102400);
      }
  }
//More Accurecy Block Ended
echo sprintf("Helllo User Your Net Surfing Speed is %0.3f kb/s", $speed);
?>

Re: Detecting Broadband?

Posted: Wed Dec 27, 2006 3:05 am
by timvw
ineededasn wrote:I was thinking about putting video on my Website, but I don't want to annoy dial-up viewers with large files loading when they visit my site. I was wondering if there was any way to detect a users connection speed so it wouldn't display the videos if their speed were too low. If anyone knows how this could be done or has any suggestions, I'd love to hear them.
I'm not a fan of websites that decide things for me... Why don't you leave that choice to them? If they find it too slow, they'll leave your site... This way, people that really, really want to see the content actually have a chance to look at it...

Posted: Wed Dec 27, 2006 3:23 am
by Rovas
If you want you can use a flah based movie player (like the one used by boreme.com) or you can use QuickTime or change the resolution for your movies.
Or you can put a link for broadband user and non- broadband users (many sites uses this). This it' s easier to code just put the two links
in 2 separate fields in table named Movies. The table should be something like this: MovieID, MovieName, BroadbandLink, MediumLink, MovieCategory, etc. And for the page you simply use query for the links.

Posted: Wed Dec 27, 2006 7:54 am
by feyd
neel_basu, your code doesn't test the speed of one's connection. Your code doesn't consider caching that many web servers will perform, proxy servers, or actually interact with the client at all. It simply dumps output and times how fast the server will perform it. The result will be way off more often than not.

Posted: Wed Dec 27, 2006 9:35 am
by neel_basu
No This Code Is To Test The Connection Speed
He Can Code Like This
If the $speed Is Greater That 256 kbs Then Video Would Be Streemed
else Not

Posted: Wed Dec 27, 2006 11:15 am
by RobertGonzalez
First run:
Helllo User Your Net Surfing Speed is 4582.321 kb/s
Second Run:
Helllo User Your Net Surfing Speed is 3123.146 kb/s
Third Run:
Helllo User Your Net Surfing Speed is 3284.288 kb/s
This doesn't seem to be that accurate on localhost.

Posted: Wed Dec 27, 2006 11:36 am
by neel_basu
No Its Not 100% Accurate Its Just To get The Current probable Speed To Decide What Should One Do Now Streem The Vidio Or Audio or not

Posted: Wed Dec 27, 2006 12:26 pm
by feyd
It's not testing how fast data can be pushed to the client though, it's testing how fast the server can push data internally. It's not a direct active connection between PHP and the requesting client. Javascript, Flash even Java can do actual speed tests. PHP cannot in this case.

Posted: Wed Dec 27, 2006 12:34 pm
by neel_basu
This Php Script Takes A Very Little Time To Test The Speed But If you Use Java Applet Or Flash To test It It Would take Too Much Time Thats Very Annoying For A Visitor
neel_basu wrote:No This Code Is To Test The Connection Speed
He Can Code Like This
If the $speed Is Greater That 256 kbs Then Video Would Be Streemed
else Not

Posted: Wed Dec 27, 2006 12:42 pm
by jayshields
Just a side note: to produce proper English grammar you do not need a capital letter at the start of every word, just at the start of sentences and names (including place names).

Posted: Wed Dec 27, 2006 12:48 pm
by neel_basu
:o :lol: :oops: :roll: Haha Does Anybody know hoW to stop it ?
Its My Mania I donno How to stop it .I Have Tried som many times

Posted: Wed Dec 27, 2006 12:50 pm
by kingconnections
I think what feyd, is trying to get at is that php is a server side script. All items are executed on the server and displayed in the client. No execution takes place on the client side of this script.

In order for correct download speed to be measured you would have to use a client side processing language ie java, or java script.

Posted: Wed Dec 27, 2006 1:03 pm
by neel_basu
BUT IT WOULD TAKE TIME THATS BORING TO A VISITOR
And If Some One Can Do It In a Very Short Of Time ( Although It May not Not Be So Accurate In A Short time test ) Then Its Good
Else
===============================
With This Script
One Can Guess The Speed how fast data can be pushed to the client
feyd wrote:how fast data can be pushed to the client
I Think Its The Shortest Way