:: Support :: Additional MP3 Player Examples: Dynamic Media Loading With FlashVars

This example shows how to use FlashVars in the embed scripts to dynamically pass the path for a single MP3 or XML playlist into the MP3 Player from the html webpage. By default, all of our example FLA and SWF files have been set up to support FlashVars, but if you are working with a modified FLA or the default MP3 component from the MXP file, you will need to follow these steps to enable the FlashVars support. This example utilizes a stand-alone MP3 component (250x24 pixels).

  1. Using your Flash 8/CS3/CS4 authoring software, open an existing FLA that includes the MP3 component, or install the MXP and add the MP3 component to the stage.

  2. Select the MP3 component on the stage and give it an instance name of "myMP3" then open the Component Inspector (in the "Window" menu) and delete any hardcoded paths for the XML and single MP3 (i.e. in the "xmlLocation" and "Single MP3" parameter fields).

  3. Open the actions panel (scene 1: frame 1) and add the following lines of action script:

    if (playlist.indexOf(".mp3") !== -1){
    } else if (playlist.indexOf(".xml") !== -1){

  4. Publish or export a network ready SWF.

  5. To add the MP3 Player SWF to your webpage you must add the following scripts to your web document wherever you want the MP3 Player to appear. Please note that the SWF path, Flash player size (width and height; should be equal to SWF dimensions), and media path (FlashVars; red text) are specified in two places. You can alter these variables to meet your needs, and you can specify a different media path for each instance of the MP3 Player on your site (e.g. you would use "playlist=song.mp3" to load a single MP3, or you would use "playlist=tracks.xml" to load a XML playlsit).

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
    width="260" height="50" >
    <param name="movie" value="mp3_flashvars.swf" />
    <param name="FlashVars" value="playlist=tracks.xml" />
    <embed src="mp3_flashvars.swf" width="260" height="50" FlashVars="playlist=tracks.xml"
    type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

  6. When loading a single MP3 file you must use the ID3 metadata information in the file to populate the title and duration fields, which means your MP3 tracks must contain ID3 metadata, and you must set the "Title Metadata Source" and "Duration Metadata Source" parameters to "ID3" in the Component Inspector.

:: Download Example Files


Support - Documentation - Skin Wizard - Sample Skins - Tutorials
Copyright © 2003-2012 Earth Science Agency, LLC - All Rights Reserved