Posts Tagged ‘MP3 Player in AIR’
14
May

A simple AIR application Program to Play, Stop and Resume the MP3 sound.

Program:-

//MP3Player.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Panel width="396" height="314" layout="absolute" horizontalCenter="0" verticalCenter="-6" borderColor="#323120" backgroundColor="#D5F5F5" fontFamily="Verdana">
<mx:Button x="47" y="86" label="Play" click="playSound();" id="btn_play" fillAlphas="[1.0, 1.0, 1.0, 1.0]" fillColors="[#7CE444, #E7ECD2]" borderColor="#F418DD" fontWeight="bold" fontFamily="Verdana"/>
<mx:Button x="151" y="86" label="Stop" id="btn_stop" click="stopSound();" fillAlphas="[1.0, 1.0]" fillColors="[#9AF85B, #D8F8F9]" borderColor="#D328E7"/>
<mx:Button x="262" y="86" label="Resume" id="btn_resume" click="resumeSound();" fillAlphas="[1.0, 1.0]" fillColors="[#6AF44A, #F0F7EE]" borderColor="#C010E6"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import adobe.utils.CustomActions;
import air.net.URLMonitor;
import flash.media.Sound;
import flash.media.ID3Info;
import flash.net.URLRequest;

var snd:Sound = new Sound(new URLRequest("app:/sound.mp3"));
var channel:SoundChannel;
var pausePosition:int;
[Bindable]
private function playSound():void
{
channel = snd.play();
}
private function stopSound():void
{
pausePosition = channel.position;
channel.stop();
}
private function resumeSound():void
{
channel = snd.play(pausePosition);
}
]]>
</mx:Script>
</mx:WindowedApplication>

Output:-