<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/05/displaying-a-dynamically-loaded-mp3-files-id3-information-in-flex-using-the-soundeffect-class/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
		layout="vertical"
		verticalAlign="middle"
		backgroundColor="white" viewSourceURL="srcview/index.html">

	<mx:Script>
		<![CDATA[
			import mx.utils.ObjectUtil;

			private const NIN_URL:String = "http://ghosts.nin.com/";

			private function playSoundEffect(src:String):void {
				textArea.text = "";

				if (soundEffect.isPlaying) {
					soundEffect.stop();
				}
				soundEffect.source = src;
				soundEffect.play([soundEffect]);
			}

			private function soundEffect_id3(evt:Event):void {
				var id3Info:ID3Info = Sound(soundEffect.sound).id3;
				textArea.text += ObjectUtil.toString(id3Info);
				textArea.text += "\n\n-------------------\n\n";
			}

			private function comboBox_change(evt:Event):void {
				var cb:ComboBox = evt.currentTarget as ComboBox;
				playSoundEffect(cb.selectedItem.@source);
			}
		]]>
	</mx:Script>

	<mx:XML id="playlist" source="data/playlist.xml" />

	<mx:SoundEffect id="soundEffect"
			duration="10000"
			useDuration="true"
			id3="soundEffect_id3(event);" />

	<mx:ApplicationControlBar dock="true">
		<mx:ComboBox id="comboBox"
				prompt="Please select a song..."
				dataProvider="{playlist.song}"
				labelField="@title"
				change="comboBox_change(event);" />
	</mx:ApplicationControlBar>

	<mx:TextArea id="textArea"
			editable="false"
			width="100%"
			height="100%" />

	<mx:LinkButton id="linkButton"
			label="All songs copyright Nine Inch Nails (2008)"
			click="navigateToURL(new URLRequest(NIN_URL), '_blank');" />

</mx:Application>

