Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Add a truly random video to any page...

  1. #1

    Default Re: Add a truly random video to any page...

    Nice. I like it.
    This member is now known as Sitting Out

  2. #2
    Join Date
    Sep 2007
    Posts
    3

    Default Re: Add a truly random video to any page...

    Hi i found your code interesting and i did some research and came up with a different way to do it.
    all credit to your code as it inspired me to do this:

    PS. im a complete PHP novice :D

    Code:
    <?
    $cnx = mysql_connect("localhost", "username", "password");
    mysql_select_db("database", $cnx);
    $sql = mysql_query("SELECT VID FROM video") or die (mysql_error());
    while($row = mysql_fetch_array($sql)){
        $row_array[] = $row['VID'];
    }
    
    $random_row = $row_array[rand(0, count($row_array) - 1)];
    
    $sql2 = mysql_query("SELECT flvdoname FROM video WHERE VID = '$random_row'") or die (mysql_error());
    
    $row = mysql_fetch_object($sql2);
    
    $flv = $row->flvdoname; 
    
    ?>
    
    <html>
    <head>
    <script src="http://www.metahump.com/ajax/cpaint2.inc.js" type="text/javascript"></script>
    <script src="http://www.metahump.com/js/myjavascriptfx.js" type="text/javascript"></script>
    <script language=JavaScript src=http://www.metahump.com/js/indexonly.js></script>
    <script language=JavaScript src=http://www.metahump.com/js/myjavascriptajax.js></script>
    <script language=JavaScript src=http://www.metahump.com/js/myjavascript.js></script>
    </head>
    
    <body>
    
    
    <?
    
    echo "<div style=\"PADDING-RIGHT: 10px; PADDING-LEFT: 10px; padding-bottom: 2px; PADDING-TOP: 10px\">\n";
    
    echo "<script type=\"text/javascript\" src=\"http://www.metahump.com/player/swfobject.js\"></script>\n";
    
    echo "<p id=\"vshare_player\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get Flash</a> to see this player.</p>\n";
    
    echo "<script type=\"text/javascript\" src=\"http://www.metahump.com/player/swfobject.js\"></script>\n";
    echo "<script type=\"text/javascript\">\n";
    echo "var so = new SWFObject(\"http://www.metahump.com/player/player.swf\",\"vshare_player\",\"425\",\"350\",\"8\");\n";
    echo "so.addParam(\"allowfullscreen\",\"true\");\n";
    echo "so.addVariable(\"file\",\"http://www.metahump.com/flvideo/", urlencode($flv), "\");\n";
    echo "so.addVariable(\"image\",\"http://www.metahump.com/thumb/", urlencode($random_row), ".jpg\");\n";
    echo "so.addVariable(\"logo\",\"http://www.metahump.com/templates/images/watermark.gif\");\n";
    echo "so.addVariable(\"link\",\"http://www.yourdomain.com\");\n";
    echo "so.addVariable(\"linktarget\",\"_blank\");\n";
    echo "so.addVariable(\"width\",\"425\");\n";
    echo "so.addVariable(\"height\",\"350\");\n";
    echo "so.addVariable(\"displayheight\",\"330\");\n";
    echo "so.addVariable(\"bufferlength\", \"5\");\n";
    echo "so.addVariable(\"overstretch\", \"true\");\n";
    echo "so.addVariable(\"autostart\", \"false\");\n";
    echo "so.write('vshare_player');\n";
    echo "</script>";
    
    echo "</div>";
    
    ?>
    
    
    </body>
    </html>

  3. #3

    Default Re: Add a truly random video to any page...

    Those are both really good scripts. I'm also tapping into the art of php. I've already got down C# among a few others, so I thought that I might try to nail php.

  4. #4
    Join Date
    Oct 2007
    Posts
    1

    Default Re: Add a truly random video to any page...

    Hello,

    Great work!

    Just one thing : the script show and play the private video for everyone... :S
    Any solution to avoid that ?

    Regards

    Pascal

  5. #5
    Join Date
    Jun 2007
    Posts
    197

    Default Re: Add a truly random video to any page...

    Hi great code!

    Hopefully the below will only show public videos and not private videos as requested above:

    Code:
    <?
    $cnx = mysql_connect("localhost", "username", "password");
    mysql_select_db("database", $cnx);
    $sql = mysql_query("SELECT VID FROM video WERE type = public") or die (mysql_error());
    while($row = mysql_fetch_array($sql)){
        $row_array[] = $row['VID'];
    }
    
    $random_row = $row_array[rand(0, count($row_array) - 1)];
    
    $sql2 = mysql_query("SELECT flvdoname FROM video WHERE VID = '$random_row'") or die (mysql_error());
    
    $row = mysql_fetch_object($sql2);
    
    $flv = $row->flvdoname; 
    
    ?>
    
    <html>
    <head>
    <script src="http://www.metahump.com/ajax/cpaint2.inc.js" type="text/javascript"></script>
    <script src="http://www.metahump.com/js/myjavascriptfx.js" type="text/javascript"></script>
    <script language=JavaScript src=http://www.metahump.com/js/indexonly.js></script>
    <script language=JavaScript src=http://www.metahump.com/js/myjavascriptajax.js></script>
    <script language=JavaScript src=http://www.metahump.com/js/myjavascript.js></script>
    </head>
    
    <body>
    
    
    <?
    
    echo "<div style=\"PADDING-RIGHT: 10px; PADDING-LEFT: 10px; padding-bottom: 2px; PADDING-TOP: 10px\">\n";
    
    echo "<script type=\"text/javascript\" src=\"http://www.metahump.com/player/swfobject.js\"></script>\n";
    
    echo "<p id=\"vshare_player\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get Flash</a> to see this player.</p>\n";
    
    echo "<script type=\"text/javascript\" src=\"http://www.metahump.com/player/swfobject.js\"></script>\n";
    echo "<script type=\"text/javascript\">\n";
    echo "var so = new SWFObject(\"http://www.metahump.com/player/player.swf\",\"vshare_player\",\"425\",\"350\",\"8\");\n";
    echo "so.addParam(\"allowfullscreen\",\"true\");\n";
    echo "so.addVariable(\"file\",\"http://www.metahump.com/flvideo/", urlencode($flv), "\");\n";
    echo "so.addVariable(\"image\",\"http://www.metahump.com/thumb/", urlencode($random_row), ".jpg\");\n";
    echo "so.addVariable(\"logo\",\"http://www.metahump.com/templates/images/watermark.gif\");\n";
    echo "so.addVariable(\"link\",\"http://www.yourdomain.com\");\n";
    echo "so.addVariable(\"linktarget\",\"_blank\");\n";
    echo "so.addVariable(\"width\",\"425\");\n";
    echo "so.addVariable(\"height\",\"350\");\n";
    echo "so.addVariable(\"displayheight\",\"330\");\n";
    echo "so.addVariable(\"bufferlength\", \"5\");\n";
    echo "so.addVariable(\"overstretch\", \"true\");\n";
    echo "so.addVariable(\"autostart\", \"false\");\n";
    echo "so.write('vshare_player');\n";
    echo "</script>";
    
    echo "</div>";
    
    ?>
    Regards,
    Mat.
    ------------------------------------
    Make an arse of yourself:
    http://www.youtwatonline.com
    ------------------------------------

  6. #6
    Join Date
    Oct 2007
    Posts
    2

    Default Re: Add a truly random video to any page...

    Very nice, I like it! However is anyone else having problems with iframe in IE? The bottom of the video is cut off.

  7. #7
    Join Date
    Feb 2008
    Posts
    3

    Default Re: Add a truly random video to any page...

    :S
    dev

  8. #8

    Default Re: Add a truly random video to any page...

    Hello

    Nice...what if i wanted to play one of the new videos or recently viewed videos from the main page using this script? Is it possible and if so, what is the coding adjustment?

  9. #9
    Join Date
    May 2007
    Location
    Planet Earth
    Posts
    1,389

    Default Re: Add a truly random video to any page...

    I would LOVE to have a random video too but not if it's going to show private videos.

    There's got to be a way to do this....I'm thinking the answer lies somewhere in the code that makes private videos private....if we know how that works, then it's probably got something to do with how that part's coded as it stands. Does it have something to do with sessions? Like, depending on who the user is that's online? Joe Blow can't view Betty Boop's videos 'cos he's not on her friends list....that same thing would have to be done to the random video display...yes?

    Private videos also do not show up in search results....another place to look for an answer?

    Just throwing out ideas.
    If it's not fun, stop doing it!

  10. #10
    Join Date
    May 2007
    Location
    Planet Earth
    Posts
    1,389

    Default Re: Add a truly random video to any page...

    Well, I know *I'm* definately going to give this a try! THANKS!!!
    If it's not fun, stop doing it!

Page 1 of 3 123 LastLast

Similar Threads

  1. Feature Request: Random Video
    By grynmoors in forum Feature Requests
    Replies: 0
    Last Post: 07-16-2008, 10:50 PM
  2. make other page with new video like in index page
    By cmedia in forum Template Modifications
    Replies: 4
    Last Post: 05-29-2008, 10:23 PM
  3. Random Video Image
    By KnoPPerS in forum Template Modifications
    Replies: 1
    Last Post: 05-01-2008, 01:58 PM
  4. Carousel Random Viewer - OUT NOW!!
    By galnet in forum Template Modifications
    Replies: 23
    Last Post: 11-29-2007, 02:06 AM
  5. Activate Random Featured Videos
    By ofir in forum General Discussions
    Replies: 6
    Last Post: 06-13-2007, 06:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •