Yii 1.1: audio-player-wordpress-plugin

Delivers Worldpress Audio Player created by 1pixelout for non-Worldpress based projects (now called aii-audio-player)

Aii Audio Player

(known also as Audio Player Wordpress Plugin )

This extensions delivers audio player, which you may use on you site. You can customize its outlook and use as many players on one page as needed. It's a port of Wordpress extension created by 1 Pixel Out with changes introduced by Mindy McAdams for non-Wordpress based sites.



  • Yii 1.0.9 or above


  • Extract the release file under protected/extensions.
  • Install AiiPublishRegisterBehavior extension


See the following code example:

/* create widget in you view file */
<?php $this->widget( 
    'AiiAudioPlayer' , 
        array ( 
            'playerID' => 'mpl',        
            'singlePlayer' => true,
            'trackOptions'=> array( 'soundFile' => 'blah.mp3' , 'alternative' => 'nothing' ),
            'flashPlayerOptions' => array( 'width' => 350 ),
    ) ); ?>

Above example creates one player which will play blah.mp3 from protected/extensions/aii-audio-player/mp3.

Everything you always wanted to know about enhanced usage of Aii


If you need to use more than one player per page, you have to set unique value of parameter `playerID' for each widget.

     * @var string - Player Id (needed when using multiple players on one site)
     * default to 'audioplayer'
    public $playerID = 'audioplayer';


If you need to use just one player per page, set the property to true

     * @var boolean, true if only one player appears on page
    public $singlePlayer = false;


It's an array specifying files to be played

     * @var array - list of mp3 files {@link mp3Folder}
     * It's an array with 4 entries
     * - soundFile - required, comma-delimited list of mp3 files
     * - alternative - required, alternative content if player will not be displayed 
     * - titles - optional, comma-delimited list of titles (overrides ID3 information) 
     * - artists - optional, comma-delimited list of artists, overrides ID3 information
     * with this way of declaration you will get one player with one or multiple mp3s.
     * Example:
     *  <code>
     *      array( 
     *          'soundFile' => "example.mp3, interview.mp3", 
     *          'titles' => "Example MP3 , My latest interview",
     *          'artists' => "Artist name 1, artist name 2"
     *          'alternative' => "sorry, no file found"
     *      );
     *  </code>
     * If you wan't to create more than one player, 
     * please pass to this property array of aforementioned options
     * with player ids. I
     * Example:
     *  <code>
     *      array(
     *          'player1' => array(
     *              'soundFile' => "poker_face-lady_gaga.mp3", 
     *              'alternative' => "sorry, no file found"
     *          ), 
     *          'player2' => array( 
     *              'soundFile' => "example.mp3, interview.mp3", 
     *              'titles' => "Example MP3 , My latest interview",
     *              'artists' => "Artist name 1, artist name 2"
     *              'alternative' => "sorry, no file found"
     *          ); 
     *      );
     *  </code>
    public $trackOptions = array( );


It's a list of player options

     * @var array list of player options
     * Below code shows also default values
     *  <code>
     *      array (
     *          'autostart' => "no",    //if yes, player starts automatically
     *          'loop'      => "no",    //if yes, player loops
     *          'animation' => "yes",   //if no, player is always open
     *          'remaining' => "no",    //if yes, shows remaining track time rather than ellapsed time
     *          'noinfo'    => "no",    //if yes, disables the track information display
     *          'initialvolume' => 60,  //initial volume level (from 0 to 100)
     *          'buffer'    => 5,       //buffering time in seconds
     *          'encode'    => "no",    //indicates that the mp3 file urls are encoded
     *          'checkpolicy' => "no"   //tells Flash to look for a policy file when loading mp3 files
     *          (this allows Flash to read ID3 tags from files hosted on a different domain)
     *          'rtl'       => "no"     //switches the layout to RTL (right to left) for Hebrew and Arabic languages
     *      );
     * </code>
     * If you would like to specify different options to each player 
     * please pass array of array options here, where key in first array is player id
     * Example:
     *  <code>
     *      array(
     *          'player1' => array ( ... ), //header options for 1st player
     *          'player2' => array ( ... ), //header options for 2nd player
     *          ...
     *          'playerN' => array ( ... ), //header options for Nth player
     *      );
     *  </code>
    public $playerOptions = array( );


It's a list of flash player options

     * @var array list of flash player options
     *  <code>
     *      array(
     *          'width' => 290,                 //required, width of the player. e.g. 290 (290 pixels) or 100%      
     *          'transparentpagebg' => "no",    //if yes, the player background is transparent (matches the page background)
     *          'pagebg' => NA,                 //player background color (set it to your page background when transparentbg is set to ‘no’) 
     *      );
     *  </code>
     * If you would like to specify different options to each player 
     * please pass array of array options here, where key in first array is player id
     * Example:
     *  <code>
     *      array(
     *          'player1' => array ( ... ), //header options for 1st player
     *          'player2' => array ( ... ), //header options for 2nd player
     *          ...
     *          'playerN' => array ( ... ), //header options for Nth player
     *      );
     *  </code> 
    public $flashPlayerOptions = array( );


It's an array of parameters helping to style the player the way you like.

     * @var array of colour scheme options
     *  <code>
     *      array(
     *          'bg' => "E5E5E5",               //Background
     *          'leftbg' => "CCCCCC",           //Speaker icon/Volume control background
     *          'lefticon' => "333333",         //Speaker icon
     *          'voltrack' => "F2F2F2",         //Volume track
     *          'volslider' => "666666",        //Volume slider
     *          'rightbg' => "B4B4B4"           //Play/Pause button background
     *          'rightbghover' => "999999"      //Play/Pause button background (hover state)
     *          'righticon' => "333333"         //Play/Pause icon
     *          'righticonhover' => "FFFFFF"    //Play/Pause icon (hover state)
     *          'loader' => "009900",           //Loading bar
     *          'track' => "FFFFFF"             //Loading/Progress bar track backgrounds
     *          'tracker' => "DDDDDD",          //Progress track
     *          'border' => "CCCCCC",           //Progress bar border
     *          'skip' => "666666",             //Previous/Next skip buttons
     *          'text' => "333333",             //Text
     *      );
     *  </code>
     * If you would like to specify different options to each player 
     * please pass array of array options here, where key in first array is player id
     * Example:
     *  <code>
     *      array(
     *          'player1' => array ( ... ), //header options for 1st player
     *          'player2' => array ( ... ), //header options for 2nd player
     *          ...
     *          'playerN' => array ( ... ), //header options for Nth player
     *      );
     *  </code>
    public $colourSchemeOptions = array( );


If you use many players on the page and you would like to set them up with the same options, this parameter is what you need.

     * Options used to initialize all players. The are overwritten 
     * options set via {@link playerOptions}, {@link flashPlayerOptions} , 
     *  <code>
     *      array(
     *          AiiAudioPlayer::OPTION_PLAYER = array ( 
     *          ... here options like in {@link playerOptions}
     *          ),
     *          AiiAudioPlayer::OPTION_FLASH = array (  
     *          ... here options like in {@link flashOptions}
     *          ),
     *          AiiAudioPlayer::OPTION_COLOUR = array ( 
     *          ... here options like in {@link colourOptions}
     *          ),
     *      );
     *  </code>
     * {@link colourSchemeOptions}
     * @var array
    public $setupOptions = array( );


Path to the mp3 you would like to play (and publish before playing them).

     * @var string - Publised folder with mp3 files
     * Default to null, which means that standard '{basepath}/mp3' folder under
     * extension directory will be published
    public $mp3Folder = null;

Change Log

Release 0.2.1

September 13,2012

  • fixed nasty bug with DEBUG option

Release 0.2.0

March 14,2010

  • extension is using now latest standalone version 2.0 of WordPress Audio Player
  • integrated with AiiPublishRegisterBehavior extension
  • array-based instead of property-based configuration of player
  • support for creating more than one players using one widget
  • support for playing more mp3 in one player
  • code clean up

Release 0.1.0

March 11,2010

(deprecated and not supported)

  • Renamed extension to yii-audio-player
  • SVN repositorry added
  • New release 0.1.0 avaliable
  • New height and widht property added
  • Enhancement error handling
  • Code clean up
  • Render method completely rewritten. Echoes used instead of view file
  • two defualt skins added

Release 0.0.1

September 19, 2009

(deprecated and not supported)

  • Initial release (not supported yet)

Total 17 comments

#14130 report it
aztech at 2013/07/22 03:53am
Re: cant get it to work

@bbunlock Assuming you put it in extension folder, you have to add it following way:in the application config file (note I use shortcut ext for extensions folder):

'import' => array(

or directly in the controller where it's used

#14118 report it
bbunlock at 2013/07/20 04:46pm
Re: cant get it to work

@aztech how do I do that? there is no information on how to use it in the config


#14117 report it
aztech at 2013/07/20 04:33pm
Re: cant get it to work

Did you include the AiiPublishRegisterBehavior in the config file?

#14084 report it
bbunlock at 2013/07/17 06:59pm
cant get it to work

I am new to yii but have managed to get most things working but I am stuck with this extension, here is what I have done so far

1) I have extracted to the files to protected/extensions/AiiAudioPlayer/

2) I have added it to my view file as follows

        array (
            'playerID' => 'in'.$data->id,
            'singlePlayer' => true,
            'trackOptions'=> array('soundFile' => $mp3_tone, 'alternative' => 'nothing'),
            'flashPlayerOptions' => array('width' => 128),

3) I have downloaded and extracted the extension "AiiPublishRegisterBehavior" to the protected/extensions/AiiPublishRegisterBehavior/ folder

and I only get the following error message

"include(AiiPublishRegisterBehavior.php): failed to open stream: No such file or directory "

I have even copied the protected/extensions/AiiPublishRegisterBehavior/AiiPublishRegisterBehavior.php to protected/extensions/AiiAudioPlayer/AiiPublishRegisterBehavior.php

but I still cannot get it to work, only shows the error mentioned above

any help would be greatfull



#13049 report it
Trejder at 2013/04/30 09:44am
Re: Example code

You may agree or disagree -- that's your free will! :] I've just pointed out, how it usually looks in other extensions' description or at Yii base. But, you're extension author, so it is up to you, how you will show it to the public... :] Cheers!

#13045 report it
aztech at 2013/04/30 09:09am
Re: Example code

I have to disagree with your suggestion. It's good to know what are features that extensions serves and how to configure the extension to use them. Usually, the problem with extensions is that you have to dig or analyse the code to ensure that the extension serves the functionality you are looking for. What I did, basing on you last post, I tried to increase the readability of description of the parameters.

#13043 report it
Trejder at 2013/04/30 07:19am
Example code

I don't think, that pasting large blocks of comments in your example code, along with all options, parameters and switches' description is a wise idea. It only blurs the most important parts. Anyone can always dig into your source code to find out this. Consider re-editing extension description and removing all the comments from example code.

#12152 report it
aztech at 2013/03/01 01:48pm
Re: Play remote files

Hi vladotg, On current implemntation it's not foreseen to use external (remote) files for playing in the player, but there is a hope for you. You may try to do following: 1) Create your own implementation of the player inheriting from my class with own implementation of method init(); 2) Add at the end of overwritten init method call


3) Pass links to mp3 files into 'otherResToPublish' property of the player.

4) Let me know if it works :)

Cheers, Tomek

#12144 report it
vladotg at 2013/02/28 06:26pm
Play remote files?

Is it possible to play remote mp3 files? Perhaps, mp3 is on url: www.mp3files.com/blah.mp3. If I set that in 'soundFile' parameter, exception is raised.

#7504 report it
alex-ks at 2012/03/26 06:37pm
J.width is undefined

It's not working with miltiple files on the page. When I set 'singlePlayer' => false, And added dynamic IDs player is not working. JS error: J.width is undefined audio-player.js (line 1) How to fix it?

this is how i setup it:

        array (
            'playerID' => 'mpl_'.$model->track_id,
            'singlePlayer' => false,
            'mp3Folder'=> 'media/audio/'.$model->album->id,
            'trackOptions'=> array( 'soundFile' => empty($model->name)? 'nothing' : $model->name , 'alternative' => 'nothing' ),
            'flashPlayerOptions' => array( 'width' => 350 ),
    ) );

UPD: Solved! problem is here X:\home\kramba\www\protected\extensions\aii-audio-player\AiiAudioPlayer.php line 412 When you change YII_DEBUG to false it not working!!!

#5279 report it
Alex Adams at 2011/09/29 08:33pm
Path confusion?

I am trying to get this working. I get the widget showing up on the view page, but it always says file not found.

Here is what I have in the widget: $file_path=Yii::app()->getBasePath().'/../hawk/audios/'.$model->internal_file_name; $this->widget('ext.aiiaudioplayer.AiiAudioPlayer', array( 'playerID'=>'audioplayer', 'singlePlayer'=>true, 'trackOptions'=>array('soundFile'=>$file_path, 'alternative'=>'nothing'), 'flashPlayerOptions'=>array('width'=>350), )); This file exists. I can download it, but I get File Not Found.

To dumb things down, I copied a file to the aiiaudioplayer/mp3 folder and hard coded it's name into the widget call:

$this->widget('ext.aiiaudioplayer.AiiAudioPlayer', array( 'playerID'=>'audioplayer', 'singlePlayer'=>true, 'trackOptions'=>array('soundFile'=>'4-jazz2.mp3', 'alternative'=>'nothing'), 'flashPlayerOptions'=>array('width'=>350), ));

Still No File Found message.




#4022 report it
dinhtrung at 2011/05/29 12:35pm
Javascript N.width error

I tried to use this extension, but could not load the player. I use Firefox 4, and the browser complain about N.width is undefined. Don't know how to fix. Download the lastest standalone version for this, but not work...

#709 report it
aztech at 2010/03/14 01:34pm
New release 0.2.0

New release uplaoded. Now palyer is integrated with latest WordPress Audio Player. Note that new interface is incompatibile with previous releases but makes extension more flexible

#726 report it
aztech at 2010/03/10 08:54pm
Thx a lot ...

Thx a lot for above remarks. Please note that new version of this extension is inroduced

#863 report it
smoothcoder at 2010/02/16 01:02pm
Eventually solved on linux

You had it all right scoob.junior even if I first missed step #3 (.swf and .js are now much bigger)

I tested on Linux Ubuntu Karmic and lighttpd webserver . Works like a charm under Firefox 3.5.7, Chrome even KDE konqueror ! My tests here

Great extension !

#1250 report it
Junior - df9 at 2009/10/14 09:32am

Three steps to get it working:

1st - make the code change in AudioPlayerWordPressPlugin.php, as I mentioned in the previous post

#register JS File $this->playerJSFile=CHtml::asset($assets.DIRECTORY_SEPARATOR.$this->playerJSFile); $cs=Yii::app()->clientScript; if($cs->isScriptRegistered($this->playerJSFile)===false)

2nd - Remove/Deactive Flash Player 9 and Install Flash Player 10

3 - Download the new version (2) of the player from this url: http://wpaudioplayer.com/download After, delete all files under extensions/APWPPLugin/assets and webapp/assets. Just paste the content of the downloaded file of the new version of the player under extensions/APWPPLugin/assets

Enjoy a new version of the player working in: Windows - FF3.5, IE8 and Chrome

Haven't tested in Linux yet.

Thanks for the great Extension!


#1251 report it
Junior - df9 at 2009/10/14 07:04am
Haven't worked for me

First, I got an error in the AudioPlayerWordPressPlugin.php. I solved it by changing #register JS File $this->playerJSFile=CHtml::asset($assets.DIRECTORY_SEPARATOR.$this->playerJSFile); $cs=Yii::app()->clientScript; if($cs->isScriptRegistered($jsFile)===false)


    #register JS File

The player now appears in the page, but when I press play button, it goes from left to right, sound starts playing and the play button returns to the left and sound stops.

This behavior was noticed in IE8, FF 3.5. Running Chrome, the sound doesn't even start.

What I'm doing wrong?



Leave a comment

Please to leave your comment.

Create extension