StevenStark.com
Technical Blog for Joomla, LAMP and Flash Development. ALSO includes Application, interactives and game development.

...... Navigation

  • Home
  • Flash
  • Open Source
  • The Team
  • Background
  • Services
  • Portfolio
  • Projects
  • Contact

  • ...... Technical Blog

  • CMS (13)
  • Experiments (1)
  • Flash (9)
  • LAMP (1)
  • Misc (8)
  • Tutorials (5)


  • ...... Archives

  • April 2009
  • October 2008
  • March 2008
  • February 2008
  • January 2008
  • November 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • December 2006
  • August 2006
  •  

     

     

     

     

     

     

     

     

     

    < RESOURCES: Joomla Components, Modules, and Mambots New into game development >

    Tutorial : Flash + CMS mp3 play list & player

    This tutorial is designed to show you how to have one of the many XML driven Flash mp3 players to list the songs uploaded to your CMS website. This example uses the Joomla CMS with the User Home Pages 2 component used to upload thet .mp3 files to user pages. A live example can be found at the bottom of the left menu on Smart-Love.ca.

    First we will need our Flash mp3 player. I am using the WebPod free ‘iPod-like’ player, also available in ’slim’, which can be displayed in white or black. This also comes with the popular swfobject and js-to-flash .js files to overcome IE embedding problems. Follow the included instructions to display the player on your website where you want it. I suggest doing this in a .php file to make things easier later on when we get to the playlist. Joomla has a mambot that is used to include .php files into content or modules which works great for this.

    Next we need to setup the XML feed. Make a new .php file and set the path for this file in the flash script you already have. The feed needs to output a simple XML file for your detailed sont information and path. Below is an example of my XML feed .php file with the database connection information removed. Since I am using User Homepages 2, which saves the page information object as a string to the database, we have to first convert the string back into an object then into an array to properly call the data inside of it.

    <tunes>
    <?php
    $query = “SELECT id, user_id, pagetitle, menutitle, pagedata from jos_uhp2_pages WHERE published = ‘1′ AND approved = ‘1′ AND pagetype=’4′ ORDER BY id DESC LIMIT 200″;
    $result = mysql_query($query);

    function object_to_array($obj) {
    $_arr = is_object($obj) ? get_object_vars($obj) : $obj;
    foreach ($_arr as $key => $val) {
    $val = (is_array($val) || is_object($val)) ? object_to_array($val) : $val;
    $arr[$key] = $val;
    }
    return $arr;
    }

    while ($row = mysql_fetch_assoc($result)) {
    $pd_obj = unserialize($row['pagedata']);
    $pd_ary = object_to_array($pd_obj);

    foreach ($pd_ary[song_file] as $key=>$value)
    {
    if($value !== “”){
    ?>

    <tune>
    <mp3>http://smart-love.ca/media/uhp2/<?php echo $row['user_id'].’/’.$value; ?></mp3>
    <title><?php echo $pd_ary[song_title][$key]; ?></title>
    <album><?php echo $pd_ary[song_album][$key]; ?></album>
    <bitrate>192</bitrate>
    <image><?php echo $pd_ary[song_image][$key]; ?></image>
    <link>http://smart-love.ca/index.php?option=com_uhp2&task=viewpage&user_id=<?php echo $row['user_id']; ?></link>
    </tune>
    <?php
    }
    }
    }

    ?>

    </tunes>

    For the play list just copy this page as a new .php file and modify the output to display instead the javascript links used to play the songs in the player. Use the include function to include this playlist.php file on the same page as the player. You should be done.


    This entry was posted on Monday, May 28th, 2007 at 8:54 am and is filed under CMS, Flash, Tutorials.
    You can follow any responses to this entry through the RSS 2.0 feed.

    © 2000 - 2008, Steven Stark of StevenStark.com
    This site is built using: | Wordpress | Flex | Wrapper | JSON | APACHE | MySQL | PHP |
    Tech Note: Content is being parsed from XHTML and rendered inside FLEX. Hosting provided by: BlueFur