Page 1 of 1

adding a description box in my code

Posted: Wed Nov 03, 2010 10:23 pm
by abbottsam1
Hey guys,

I was wondering if it is possible to add like a desciption feild into this script:

Code: Select all


<div class="demo-canvas">
  <div style="float: left; width: 555px; height: 450px;">
    <a name="ytplayer"></a>
    <div id="ytplayer_div1">You need Flash player 8+ and JavaScript enabled to view this video.</div>
  </div>
  <div style="float: left; width: 160px; height: 450px; overflow-y: scroll;">

    <div id="ytplayer_div2"></div>
  </div>
  <br style="clear: both;" />
  <br style="clear: both;" />
</div>
<script type="text/javascript" src="http://tsunami-guild.cz.cc/swfobject/swfobject.js"></script>
<script type="text/javascript">
  //
  // YouTube JavaScript API Player With Playlist
  // http://911-need-code-help.blogspot.com/2009/10/youtube-javascript-player-with-playlist.html
  // Revision 1 [2009-10-12]
  //
  // Prerequisites
  // 1) Create following elements in your HTML:
  // -- a) ytplayer: a named anchor
  // -- b) ytplayer_div1: placeholder div for YouTube JavaScript Player
  // -- c) ytplayer_div2: container div for playlist
  // 2) Include SWFObject library from http://code.google.com/p/swfobject/
  //
  // Variables
  // -- ytplayer_playlist: an array containing YouTube Video IDs
  // -- ytplayer_playitem: index of the video to be played at any given time
  //
  var ytplayer_playlist = [ ];
  var ytplayer_playitem = 0;
  swfobject.addLoadEvent( ytplayer_render_player );
  swfobject.addLoadEvent( ytplayer_render_playlist );
  function ytplayer_render_player( )
  {
    swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + ytplayer_playlist[ ytplayer_playitem ] + '&enablejsapi=1&rel=0&fs=1',
      'ytplayer_div1',
      '555',
      '450',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer_object'
      }
    );
  }
  function ytplayer_render_playlist( )
  {
    for ( var i = 0; i < ytplayer_playlist.length; i++ )
    {
      var img = document.createElement( "img" );
      img.src = "http://img.youtube.com/vi/" + ytplayer_playlist[ i ] + "/default.jpg";
      var a = document.createElement( "a" );
      a.href = "#ytplayer";
      //
      // Thanks to some nice people who answered this question:
      // http://stackoverflow.com/questions/1552941/variables-in-anonymous-functions-can-someone-explain-the-following
      //
      a.onclick = (
        function( j )
        {
          return function( )
          {
            ytplayer_playitem = j;
            ytplayer_playlazy( 1000 );
          };
        }
      )( i );
      a.appendChild( img );
      document.getElementById( "ytplayer_div2" ).appendChild( a );
    }
  }
  function ytplayer_playlazy( delay )
  {
    //
    // Thanks to the anonymous person posted this tip:
    // http://www.tipstrs.com/tip/1084/Static-variables-in-Javascript
    //
    if ( typeof ytplayer_playlazy.timeoutid != 'undefined' )
    {
      window.clearTimeout( ytplayer_playlazy.timeoutid );
    }
    ytplayer_playlazy.timeoutid = window.setTimeout( ytplayer_play, delay );
  }
  function ytplayer_play( )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.loadVideoById( ytplayer_playlist[ ytplayer_playitem ] );
    }
  }
  //
  // Ready Handler (this function is called automatically by YouTube JavaScript Player when it is ready)
  // * Sets up handler for other events
  //
  function onYouTubePlayerReady( playerid )
  {
    var o = document.getElementById( 'ytplayer_object' );
    if ( o )
    {
      o.addEventListener( "onStateChange", "ytplayer_statechange" );
      o.addEventListener( "onError", "ytplayer_error" );
    }
  }
  //
  // State Change Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_statechange( state )
  {
    if ( state == 0 )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Error Handler
  // * Sets up the video index variable
  // * Calls the lazy play function
  //
  function ytplayer_error( error )
  {
       if ( error )
    {
      ytplayer_playitem += 1;
      ytplayer_playitem %= ytplayer_playlist.length;
      ytplayer_playlazy( 5000 );
    }
  }
  //
  // Add items to the playlist one-by-one
  //
<?php
$connection = mysql_connect('server', 'user', 'password');
mysql_select_db('tsunamiguild_fom');
$result = mysql_query('SELECT youtube_id FROM queue_videos ORDER BY youtube_id DESC');
while ($row = mysql_fetch_assoc($result)) {
    echo 'ytplayer_playlist.push(\'' . $row['youtube_id'] . '\');' . PHP_EOL;
}
?>
</script>
I personally have no idea how it would be done,
i use this gallery script on my website to show users videos i enter into the database, (with a html form).
it is a bit confusing for them to see what the videos name and what it is about, is it somehow possible to pull data from anotherfeild in that database (which i must make - and the data will also be added by a form there) and show it .. lets say, under the thumbnail it already makes ?

any answers would be appreciated :)

Thanks guys.
Sam.
(gallery live: http://samsworld.megabyet.net/gallery.php (if it helps ))