Umbraco - Macro -XSLT - Flash Audio Player
Umbraco - Macro -XSLT - Flash Audio Player
To create a Flash based Audio Player for Umbraco, that will allow users to choose their own audio file, is easily done in 3 steps:
Step 1). Find a Flash Audio Player you like.
I used this one: http://flash-mp3-player.net/players/mini/generator/ , it is clean and simple and is used in the code below.
There are a lot of others that are easily integrated with the code below: http://savedelete.com/top-25-best-free-online-music-players-for-your-websites-or-blogs.html
Step 2). Upload the Audio Player to your site
Upload the Audio Player to your folder structure. In the XSLT below the file is being referenced in a folder called "audioplayer".
Step 3) Create a XSLT file with a relate Macro.
A: Paste in this code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:variable name="location" select="/macro/location"/>
<xsl:variable name="title" select="/macro/title"/><xsl:template match="/">
<h3><xsl:value-of select="/macro/title"/> </h3>
<br />
<object type="application/x-shockwave-flash" data="/audioplayer/player_mp3_mini.swf" width="200" height="20">
<param name="movie" value="/audioplayer/player_mp3_mini.swf" />
<param name="bgcolor" value="#000000" />
<param name="FlashVars" value="mp3={$location}" />
</object><ul>
<li>You can download the audio file <a href="{$location}" title="">here</a>.</li>
</ul>
</xsl:template>
</xsl:stylesheet>
Explanation to the code above:
The code in green is declaring the paramaters that the user will enter - the title of the podcast and its location, for example "My Podcast", /media/12345/my-podcast.mp3
The code in Yellow is specific to the Flash Player I chose in Step 1. I have simply replaced the location of an mp3 with a reference to the paramater "{$location}"
B: Add Paramaters to the Macro
- location
- title
3) Save the Macro
1) Upload a Audio file to Umbraco
3) Click on the Macro button and select the new macro from the drop down.
4) For the location, paste in the URL of the Audio. Such as:
/media/1234/my-audio-file.mp3 (or an external url)
5) Enter the title of the file.
Comments
Post a Comment