Location: PHPKode > scripts > splay > splay/class.splay.php
<?php



  interface isplay  {

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
    *                                                                         *
    * Class for displaying version 2 of the flash WordPress Audio Player      *
    *                                                                         *
    * Author: Carl Friis-Hansen - carl dot friis-hansen at carl-fh dot com    *
    * Licens: BSD
    * Date  : 20090830                                                        *
    * Ver.  : 1.2                                                             *
    * Update: 20090831                                                        *
    *                                                                         *
    * Prerequisites in directory from where parent script is run:             *
    *   ln -s /var/www/clients/php-class/audio-player.js  audio-player.js     *
    *   ln -s /var/www/clients/php-class/player.swf  player.swf               *
    * Substitute the path with the actual location of the two files.          *
    *                                                                         *
    * After constructing the class, you can printout("mySong.mp3") any number *
    * of sound files.  Mostly anything goes like mp3, eav, etc.               *
    *                                                                         *
    * Reference: http://wpaudioplayer.com/standalone                          *
    *                                                                         *
    \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    //  Constructor:
    public  function  __construct         ();

    //  Implementation(s):
    public  function  printout            ( $filename, $title="", $artist="" );
                      //  All parameters can optionally contain a comma delimited list for mutiple tracks.
                      //  If no titles and/or artists then the ID3 tags from the files will be used where present.

    //  Options:
    public  function  setbgcolor          ( $bgcolor        );  //  Default #FF9900 (if transparentpagebg=="no")
    public  function  settransparentpagebg( $ransparent     );  //  Default yes
    public  function  setinitialvolume    ( $initialvolume  );  //  Default 60
    public  function  setautostart        ( $autoplay       );  //  Default no
    public  function  setloop             ( $loop           );  //  Default no
    public  function  setanimation        ( $animation      );  //  Default yes
    public  function  setremaining        ( $remaining      );  //  Default no
    public  function  setnoinfo           ( $noinfo         );  //  Default no
    public  function  setwidth            ( $width          );  //  Default 290

    /* * * * * * * * * * * * * * Add. info * * * * * * * * * * * * * * * *

    $height = "42"  (Default)
    A public variable $splay_active can be used to check if splay has been instantiated:
    if( $splay::splay_active ) {
      echo "class splay's constructor has been called.";
    } else {
      echo "class splay's constructor has never been called.";
    }

     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /* * * * * * * * * * * * * * Example * * * * * * * * * * * * * * * * *

    $sound = new splay;
    print "A long Google story: \n";
    $sound->setnoinfo( "yes" );
    $sound->printout( "http://www.stanford.edu/group/edcorner/uploads/podcast/mayer060517.mp3" );
    print "<br />\n";

     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

  } //  interface isplay


    class splay implements  isplay  {



    public
      $splay_active   = false;



    protected
      $splay_ID,
      $autoplay       = "true",
      $bgcolor        = "#FF9900",
      $ransparent     = "yes",
      $initialvolume  = "60",
      $loop           = "no",
      $animation      = "yes",
      $remaining      = "no",
      $noinfo         = "no",
      $width          = "290";



    public  function  __construct () {
      $this->splay_active = true;
      print "
         <script type=\"text/javascript\" src=\"http://".$_SERVER["HTTP_HOST"]."/audio-player.js\"></script>  
         <script type=\"text/javascript\">  
             AudioPlayer.setup(\"http://".$_SERVER["HTTP_HOST"]."/player.swf\", {});  
         </script>  
        ";
    }



    public  function  printout( $filename, $title="", $artist="" ) {
      $this->splay_ID = rand();
      print "
        <p id=\"audioplayer_".$this->splay_ID."\">Long speech</p>  
        <script type=\"text/javascript\">  
        AudioPlayer.embed(\"audioplayer_".$this->splay_ID."\", {
        ";
      $params =     "   soundFile:          \"".$filename."\"";
      $params .= ",\n   transparentpagebg:  \"".$this->ransparent."\"";
      $params .= ",\n   pagebg:             \"".$this->bgcolor."\"";
      $params .= ",\n   initialvolume:      \"".$this->initialvolume."\"";
      $params .= ",\n   autostart:          \"".$this->autoplay."\"";
      $params .= ",\n   loop:               \"".$this->loop."\"";
      $params .= ",\n   animation:          \"".$this->animation."\"";
      $params .= ",\n   remaining:          \"".$this->remaining."\"";
      $params .= ",\n   noinfo:             \"".$this->noinfo."\"";
      $params .= ",\n   width:              \"".$this->width."\"";
      if( $title  ) $params .= ",\n   titles:             \"".$title."\"";
      if( $artist ) $params .= ",\n   artists:            \"".$artist."\"";
      print $params."
        });  
        </script>  
        ";
    }



    public  function  setbgcolor( $bgcolor ) {
      $this->bgcolor = $bgcolor;
    }

    public  function  settransparentpagebg( $ransparent ) {
      $this->ransparent = $ransparent;
    }

    public  function  setinitialvolume( $initialvolume ) {
      $this->initialvolume = $initialvolume;
    }

    public  function  setautostart( $autoplay ) {
      $this->autoplay = $autoplay;
    }

    public  function  setloop( $loop ) {
      $this->loop = $loop;
    }

    public  function  setanimation( $animation ) {
      $this->animation = $animation;
    }

    public  function  setremaining( $remaining ) {
      $this->remaining = $remaining;
    }

    public  function  setnoinfo( $noinfo ) {
      $this->noinfo = $noinfo;
    }

    public  function  setwidth( $width ) {
      $this->width = $width;
    }



  } //  class	splay



?>
Return current item: splay