Playing back the recorded voice message

Tech Insights

As you all know, to play the sound, you will need some kind of player which will take the audio file as input and produce the sound as output.

So we will use a Flash player for this. Have a look @ this

Its an mp3 player basically. It can handle flv, mp4, etc.

If you have your voice file in some other format like wav, you will need to convert that into mp3 or any other supported format.

OR

You can use any other player. For most of them code part will be the same. To convert wav format into mp3, you can use utilities like LAME on Linux.

Now we will see the client side code to be added to your page. Just add the following to your page

<embed src="mp3player.swf" width="250" height="19"
allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
flashvars="&file=filename&height=19&width=250&showdigits=true&bufferlength=3"/>
</embed>

where, src will be the url to the player. So put the swf player somewhere in ur application path. You can decide which all flashvars to use.

Remember, this code may be old and to embed the swf files, nowadays, people create objects of SWFObject and use addParam() method to specify the properties. Getting this won’t be a problem for you.

Anyways you just need to give the input audio file. Flash player will play it for you.

Please reply for any queries.

Thanx 🙂

Sandeep.