<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abhi&#039;s Weblog &#187; Flash</title>
	<atom:link href="http://abhinavsingh.com/blog/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Mon, 27 Feb 2012 09:12:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to create a single button flash audio player using Openlaszlo?</title>
		<link>http://abhinavsingh.com/blog/2008/10/how-to-create-a-single-button-flash-audio-player-using-openlaszlo/</link>
		<comments>http://abhinavsingh.com/blog/2008/10/how-to-create-a-single-button-flash-audio-player-using-openlaszlo/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 11:47:56 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Audioplayer]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flashplayer]]></category>
		<category><![CDATA[OpenLaszlo]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/10/how-to-create-a-single-button-flash-audio-player-using-openlaszlo/</guid>
		<description><![CDATA[Hello Everyone, I have been working on OpenLaszlo for quite sometime now and found it every easy to build custom flash widgets using it. In my first tutorial on OpenLaszlo, we will together learn a few specs of Openlaszlo and then code a tiny little flash media player. Getting started with Openlaszlo: Openlaszlo is a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fhow-to-create-a-single-button-flash-audio-player-using-openlaszlo%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fhow-to-create-a-single-button-flash-audio-player-using-openlaszlo%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Audioplayer,Flash,Flashplayer,OpenLaszlo,Web+Development&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello Everyone,</p>
<p>I have been working on <a href="http://OpenLaszlo.org">OpenLaszlo</a> for quite sometime now and found it every easy to build custom flash widgets using it. In my first tutorial on OpenLaszlo, we will together learn a few specs of Openlaszlo and then code a tiny little flash media player.</p>
<p><span style="font-weight: bold;"><span style="text-decoration: underline; color: rgb(51, 51, 255);">Getting started with Openlaszlo:</span><br />
</span>
<ol>
<li>Openlaszlo is a framework which allows you to build flash widgets easily and faster. Biggest advantage is that you need not write any action scripting for building your flash widget. In laszlo we write code in XML format (files saved with extension .lzx) and then Laszlo server compiles our .lzx files to output a flash .swf file. WOW!</li>
<li>Download your copy of laszlo from <a href="http://openlaszlo.org/download">http://openlaszlo.org/download</a> and install. If you are on windows, installation is simple. Just double click the downloaded .exe file and it will install everything for you. For me my installation is at <span style="font-weight: bold;">C:\OpenLaszlo Server 4.0.12</span>
</li>
<li>Create a directory <span style="font-weight: bold;">C:\OpenLaszlo Server 4.0.12\Server\lps-4.0.12\Workspace</span> . I generally do all my laszlo specific development under Workspace directory. (Adjust the path as per your installation)</li>
<li>Create a folder inside Workspace named <span style="font-weight: bold;">audioplayer</span></li>
<li>Start the laszlo server.</li>
</ol>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">Building an audioplayer in laszlo:</p>
<p></span><span style="color: rgb(0, 0, 0);">Before we proceed you may checkout the code repository from Google Code Base:</span></p>
<div style="border: 1px dotted rgb(153, 153, 153); padding: 5px; background: rgb(221, 221, 221) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-top: 5px; margin-bottom: 5px;">svn checkout http://abhinavsingh.googlecode.com/svn/trunk/ abhinavsingh-read-only
</div>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);"></span>
<ol>
<li>As I wrote before, laszlo code files have an extension called .lzx . Lets first see a demo and then we will learn the syntaxes etc. You can find the explanation of the codes below within the code as comments
</li>
<li>Create a file called <span style="font-weight: bold;">main.lzx </span>and copy paste the following lines of code in it:
<div style="border: 1px dotted rgb(153, 153, 153); padding: 5px; background: rgb(221, 221, 221) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-top: 5px; margin-bottom: 5px;">&lt;canvas id=&#8221;miniplayer&#8221; medialoadtimeout=&#8221;120000&#8243; bgcolor=&#8221;#FFFFFF&#8221; debug=&#8221;true&#8221;&gt;<br />
&nbsp;<br />
&nbsp; &lt;!&#8211; This file takes care of toggling for the play/pause button &#8211;&gt;<br />
&nbsp; &lt;include href=&#8221;playpausemultibutton.lzx&#8221;/&gt;<br />
&nbsp;<br />
&nbsp; &lt;!&#8211; Include the MP3 player class &#8211;&gt;<br />
&nbsp; &lt;include href=&#8221;player.lzx&#8221;/&gt;<br />
&nbsp;<br />
&nbsp; &lt;!&#8211; Main view containing everything within it &#8211;&gt;<br />
&nbsp; &lt;view x=&#8221;5&#8243;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;simplelayout axis=&#8221;x&#8221; spacing=&#8221;5&#8243;/&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; PLAY-PAUSE BUTTON PANEL &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;view name=&#8221;buttonpanel&#8221; id=&#8221;buttonpanel&#8221; y=&#8221;1&#8243; bgcolor=&#8221;#EEEEEE&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;multistatebutton id=&#8221;playpausetoggle&#8221; name=&#8221;playpausetoggle&#8221; bgcolor=&#8221;#EEEEEE&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resource=&#8221;playpause_rsrc&#8221; align=&#8221;center&#8221; statenum=&#8221;0&#8243; statelength=&#8221;2&#8243; maxstate=&#8221;1&#8243; onclick=&#8221;this.toggle()&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;method name=&#8221;toggle&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (this.statenum == 0) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setStateNum(1);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; if players is already loaded with a song just play it, otherwise load it again with mp3url &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(audioplayer.nowplaying == false) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audioplayer.setAttribute(&#8220;nowplaying&#8221;,true);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audioplayer.setResource(global.mp3url);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audioplayer.play();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setStateNum(0);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audioplayer.stop();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/method&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/multistatebutton&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/view&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Include the audioplayer class &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;player id=&#8221;audioplayer&#8221; width=&#8221;100%&#8221; height=&#8221;100%&#8221;/&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp; &lt;/view&gt;<br />
&lt;/canvas&gt;
</div>
</li>
<li>Create a file called <span style="font-weight: bold;">playpausemultibutton.lzx</span> and copy paste the following lines of code in it:
<div style="border: 1px dotted rgb(153, 153, 153); padding: 5px; background: rgb(221, 221, 221) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-top: 5px; margin-bottom: 5px;">&lt;library&gt;<br />
&nbsp; &lt;resource name=&#8221;playpause_rsrc&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211;&nbsp; State: 0 &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; first&nbsp; frame of state 1 = mouseup&nbsp;&nbsp; image of the button &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;frame src=&#8221;icons/play_blue.png&#8221;/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; third&nbsp; frame of state 1 = mousedown image of the button &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;frame src=&#8221;icons/pause_blue.png&#8221;/&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211;&nbsp; State: 1 &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; first&nbsp; frame of state 2 = mouseup image of the button &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;frame src=&#8221;icons/pause_blue.png&#8221;/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; third&nbsp; frame of state 2 = mousedown image of the button &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;frame src=&#8221;icons/play_blue.png&#8221;/&gt;<br />
&nbsp; &lt;/resource&gt;<br />
&lt;/library&gt;
</p></div>
</li>
<li>Create a file called <span style="font-weight: bold;">player.lzx</span> and copy paste the following lines of code in it:
<div style="border: 1px dotted rgb(153, 153, 153); padding: 5px; background: rgb(221, 221, 221) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-top: 5px; margin-bottom: 5px;">&lt;library&gt;<br />
&nbsp;<br />
&nbsp; &lt;!&#8211; THE AUDIOPLAYER PLAYING CLASS &#8211;&gt;<br />
&nbsp; &lt;class name=&#8221;player&#8221; extends=&#8221;view&#8221; visible=&#8221;true&#8221; play=&#8221;false&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Attribute which captures the player nowplaying stat &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;attribute name=&#8221;nowplaying&#8221; value=&#8221;false&#8221;/&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Attribute which captures the player loading stat &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;attribute name=&#8221;loading&#8221; value=&#8221;false&#8221;/&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onlastframe&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onlastframe&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setAttribute(&#8220;nowplaying&#8221;,false);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setAttribute(&#8220;loading&#8221;,false);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; playpausetoggle.toggle();<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onloadperc&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onloadperc&#8221; args=&#8221;p&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(p &gt; 0) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(p &amp;lt; 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audioplayer.setAttribute(&#8220;loading&#8221;,true);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if(p == 1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; audioplayer.setAttribute(&#8220;loading&#8221;,&#8221;done&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onunload&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onunload&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(this.nowplaying) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setAttribute(&#8220;nowplaying&#8221;,false);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.stop();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onplay&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onplay&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.setAttribute(&#8220;nowplaying&#8221;,true);<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onload&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onload&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onframe&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onframe&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;onstop&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;onstop&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; &lt;!&#8211; Write &#8216;ontimeout&#8217; handler &#8211;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;handler name=&#8221;ontimeout&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;/handler&gt;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp; &lt;/class&gt;<br />
&nbsp;<br />
&lt;/library&gt;
</div>
</li>
<li>Create a file called <span style="font-weight: bold;">mediaplayer_dev.html </span>and copy paste the following lines of code in it: (This is development environment file, mediaplayer.html is the production environment file which you can find in code repository)
<div style="border: 1px dotted rgb(153, 153, 153); padding: 5px; background: rgb(221, 221, 221) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-top: 5px; margin-bottom: 5px;">&lt;html&gt;<br />
&nbsp; &lt;head&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;title&gt;Flash Audio Player&lt;/title&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;script type=&#8221;text/javascript&#8221; src=&#8221;swfobject.js&#8221;&gt;&lt;/script&gt;<br />
&nbsp; &lt;/head&gt;<br />
&nbsp; &lt;body&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;div id=&#8221;flashcontent&#8221; width=&#8221;100%&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This text is replaced by the Flash movie.<br />
&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;script type=&#8221;text/javascript&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var so = new SWFObject(&#8220;main.lzx?lzt=swf&amp;debug=true&#8221;, &#8220;singlebuttonplayer&#8221;, &#8220;100%&#8221;, &#8220;100%&#8221;, &#8220;7&#8243;, &#8220;#FFFFFF&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;quality&#8221;, &#8220;high&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;scale&#8221;, &#8220;exactfit&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;salign&#8221;, &#8220;LT&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;menu&#8221;, &#8220;false&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;wmode&#8221;, &#8220;opaque&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;allowScriptAccess&#8221;, &#8220;always&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Set the mp3urlfor the song<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addVariable(&#8220;mp3url&#8221;,&#8221;http://127.0.0.1:8080/lps-4.0.12/Workspace/audioplayer/Liquid Tension Experiment &#8211; Acid Rain.mp3&#8243;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.write(&#8220;flashcontent&#8221;);<br />
&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br />
&nbsp; &lt;/body&gt;<br />
&lt;/html&gt;
</div>
</li>
<li>Create a folder called <span style="font-weight: bold;">icons</span> and copy the two icons which you checked out from the code repository.</li>
<li>Copy an <span style="font-weight: bold;">mp3 file </span>from your hard disk and copy paste it in the folder. Then edit the mp3url in above code of mediaplayer_dev.html</li>
<li>Copy and paste the <span style="font-weight: bold;">swfobject.js</span> file which you have checked out from code repository.
</li>
</ol>
<p>That all we need to test run our single button audio player. Now simply open the following URL in your browser: (edit it as per your folder names)<br />
<a href="http://127.0.0.1:8080/lps-4.0.12/Workspace/audioplayer/mp3player_dev.html">http://127.0.0.1:8080/lps-4.0.12/Workspace/audioplayer/mp3player_dev.html</a><br />
and you can see the audio player playing your mp3 song <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now we can see our file playing the mp3 well and we would like to generate a flash file out of our main.lzx file. For this laszlo have their inbuild compilers which will compile the flash file for you. Simply open the url:<br />
<a href="http://127.0.0.1:8080/lps-4.0.12/Workspace/audioplayer/main.lzx">http://127.0.0.1:8080/lps-4.0.12/Workspace/audioplayer/main.lzx</a><br />
and then check <span style="font-weight: bold;">swf8</span> at the bottom of the page under compile options and <span style="font-weight: bold;">press compile</p>
<p></span>From here on you have two options:</p>
<ol>
<li>Either to use laszlo specific embedding strategy i.e. If you proceed with further steps after pressing compile, laszlo will give you a set of javascript files which you can use to embed your audio player.</li>
<li>Or you can use swfobject.js to embed your flash files in your website. (Recommended)</li>
</ol>
<p>I assume you will use swfobject.js and in that case you may simply stop after pressing compile. See the folders and you can see&nbsp; two .swf files being generated into the folder. These are our final production level flash audio player files.</p>
<p>Now lets see how to use these .swf files in our pages. Simply rename them to alterplayer.swf and create a file called <span style="font-weight: bold;">mediaplayer.html </span>and copy paste the below code in it:</p>
<div style="border: 1px dotted rgb(153, 153, 153); padding: 5px; background: rgb(221, 221, 221) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-top: 5px; margin-bottom: 5px;">&lt;html&gt;<br />
&nbsp; &lt;head&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;title&gt;Flash Audio Player&lt;/title&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;script type=&#8221;text/javascript&#8221; src=&#8221;swfobject.js&#8221;&gt;&lt;/script&gt;<br />
&nbsp; &lt;/head&gt;<br />
&nbsp; &lt;body&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;div id=&#8221;flashcontent&#8221; width=&#8221;100%&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This text is replaced by the Flash movie.<br />
&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;script type=&#8221;text/javascript&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var so = new SWFObject(&#8220;alterplayer.swf&#8221;, &#8220;singlebuttonplayer&#8221;, &#8220;100%&#8221;, &#8220;100%&#8221;, &#8220;7&#8243;, &#8220;#FFFFFF&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;quality&#8221;, &#8220;high&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;scale&#8221;, &#8220;exactfit&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;salign&#8221;, &#8220;LT&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;menu&#8221;, &#8220;false&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;wmode&#8221;, &#8220;opaque&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addParam(&#8220;allowScriptAccess&#8221;, &#8220;always&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Set the mp3urlfor the song<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.addVariable(&#8220;mp3url&#8221;,&#8221;http://mysite.com/songname.mp3&#8243;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; so.write(&#8220;flashcontent&#8221;);<br />
&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br />
&nbsp; &lt;/body&gt;<br />
&lt;/html&gt;
</div>
<p>We did not much change from mediaplayer_dev.html. Simply replaced .lzx file with actual .swf file and the mp3url also change to your production level mp3 url.</p>
<p>Thats pretty much of what we actually wanted to have. <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In future we will see how to build a:</p>
<ol>
<li>Single Button Player which also shows the time</li>
<li>Single Button Player with progress bar and volume control</li>
<li>Audio Player capable of playing a whole mp3 playlist.</li>
<li>Audio Player with AJAX search enabled in it.</li>
</ol>
<p>If you want to see the final version of flash player which we will slowly learn to develop, kindly visit <a href="http://Altertunes.com">Altertunes</a> (my first ever site <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>Kindly let me know if you are having trouble in learning and running this player. I will more than happy to contribute and share further.</p>
<p><span style="font-weight: bold;"><span style="text-decoration: underline; color: rgb(51, 51, 255);">Document Reference:</span><br />
</span>
<ol>
<li><a href="http://www.openlaszlo.org/lps4/docs/">http://www.openlaszlo.org/lps4/docs/</a></li>
<li><a href="http://www.openlaszlo.org/lps3/docs/reference/">http://www.openlaszlo.org/lps3/docs/reference/</a></li>
<li>You can find some great help from the official forum <a href="http://forum.openlaszlo.org/">http://forum.openlaszlo.org/</a></li>
</ol>
<p>Let me know your feedbacks.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F10%2Fhow-to-create-a-single-button-flash-audio-player-using-openlaszlo%2F","http:\/\/OpenLaszlo.org","http:\/\/openlaszlo.org\/download","http:\/\/127.0.0.1:8080\/lps-4.0.12\/Workspace\/audioplayer\/mp3player_dev.html","http:\/\/127.0.0.1:8080\/lps-4.0.12\/Workspace\/audioplayer\/main.lzx","http:\/\/Altertunes.com","http:\/\/www.openlaszlo.org\/lps4\/docs\/","http:\/\/www.openlaszlo.org\/lps3\/docs\/reference\/","http:\/\/forum.openlaszlo.org\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzEwL2hvdy10by1jcmVhdGUtYS1zaW5nbGUtYnV0dG9uLWZsYXNoLWF1ZGlvLXBsYXllci11c2luZy1vcGVubGFzemxvLzx3cHRiPkhvdyB0byBjcmVhdGUgYSBzaW5nbGUgYnV0dG9uIGZsYXNoIGF1ZGlvIHBsYXllciB1c2luZyBPcGVubGFzemxvPzx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/05/essential-frameworks-for-web-development/" title="Essential frameworks for web development">Essential frameworks for web development</a> (2)</li><li><a href="http://abhinavsingh.com/blog/2009/07/getting-started-with-openlaszlo-framework-for-developing-flash-apps/" title="Getting started with Openlaszlo &#8211; Framework for developing flash apps">Getting started with Openlaszlo &#8211; Framework for developing flash apps</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2008/07/how-to-get-started-with-web-development/" title="How to get started with web development?">How to get started with web development?</a> (9)</li><li><a href="http://abhinavsingh.com/blog/2008/05/web-development-part-1-apache-mysql-php/" title="Web Development &#8211; Part 1: Apache, MySQL, PHP">Web Development &#8211; Part 1: Apache, MySQL, PHP</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/10/how-to-create-a-single-button-flash-audio-player-using-openlaszlo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

