setcooki
ALLROUND WEB DEVELOPER

15
Oct 11

WP SimpleDesign multi instance Amazon S3 Player Tweak

  
  
  

The iSimpleDesign Amazon S3 Player lets you access your S3 Account to playback your .mp3 files with the AS3 Flash Dewplayer. See (http://wordpress.org/extend/plugins/isimpledesign-amazon-s3-music-player-plugin/) for more. All you need to do is enter your credentials in the plugin properties in the backend and you are good to go … But!

For some the player simply wont do nothing since the credentials (S3 Access Keys) are not valid once passed via GET to PHP file responsible for outputting the .xml string for the Dewplayer. See comments at the developer website for more (http://www.isimpledesign.co.uk/blog/amazon-s3-music-player-mp3-player-audio-player). Also, and this i find a major drawback, it only lets you put one instance of the player across your whole blog. So if you want have multiple instances – here is what you have to do and tweak:

  1. Install the PHP Exec plugin (http://wordpress.org/extend/plugins/exec-php/) so you can put php code directly into your post or page
  2. Install the iSimpleDesign plugin and enter your credentials in the backend (leave folder blank!)
  3. Open the file “amazon-s3-player.php” in the “isimpledesign-amazon-s3-music-player-plugin” plugin folder and change the following code:
    // Base function
    function isd_s3player($_folder = null) {
    
    // Plugin Url
    $s3url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
    
    $amazon_key	= get_option("isd-amazon_key");
    $amazon_secret_key	= get_option("isd-amazon_secret_key");
    $bucket	= get_option("isd-bucket");
    if($_folder !== null)
    {
        $folder	= $_folder;
    }else{
        $folder	= get_option("isd-folder");
    }
    
    $test = $amazon_key."-".$amazon_secret_key."-".$bucket."-".$folder;
    
    ....

    this lets you pass a folder name to the php function responsible for generating the playlist .xml list.

  4. then open the file “playlist.php” and exchange the following code in the top of the file:
    $bucket	= $_GET["name"];
    $store = explode("-", $bucket);
    if(!empty($store[3]))
    {
        $store[3] = rtrim($store[3], "/") . "/";
    }...

    this is to make sure that we always have a backslash at the end of the folder name. we can now pass the folder name to the player and use multiple instances in the same post or blog.

  5. finally you can use the php function isd_s3player() in your post or page to use multiple instances accross your blog or even post by simple pasting the function with php code directly into the wysiwyg editor like:

    All you need to do is pass the folder name as first parameter of the function et voila.

So you could say that only a small backslash did the trick … Further tweaks could be including a ID3 Parser and extending the configuration so Dewplayer properties can also be controlled from backend.

Hope it helps somebody

  • setcookie

    you can also extend the “function isd_s3player($_folder = null)” to accept a second parameter “autostart” which can be very helpfull once there are more then one instance on one page!

  • setcookie

    you can also extend the “function isd_s3player($_folder = null)” to accept a second parameter “autostart” which can be very helpfull once there are more then one instance on one page!

  • productions

    awesome i tweaked that


Copyright © 2012 setcooki
Proudly powered by WordPress, Free WordPress Themes