/ Published in: ActionScript
I needed a way to dynamically stream mp3s. I coupled this with an XML File that had all the mp3's listed.
Expand |
Embed | Plain Text
/************************* Initialize Variables *************************/ var pos:Number; var s:Sound = new Sound(); s.onSoundComplete = playSong; s.setVolume(75); /************************* Play Song *************************/ function playSong(song:String){ s = new Sound(); s.onSoundComplete = playSong; s.setVolume(75); this.onEnterFrame = checkSound; s.loadSound(song, true); } function checkSound(){ var percent:Number = Math.round((s.position / s.duration) * 100); if(percent != NaN){ trace(percent); } } /************************* Pause Song (Create a Button that says play_btn.onRelease = pauseSong;) *************************/ function pauseSong():Void{ pos = s.position; s.stop(); } function unpauseSong():Void{ s.start((pos/1000)); } /************************* onLoad *************************/ playSong("http://www.somesite.com/file.mp3");
You need to login to post a comment.
