Click to See Complete Forum and Search --> : flash music player?
wigga
June 23rd, 2009, 09:32 AM
hello i have been given this school assignment to create a music player with flash.
I am loading the playlist with XML. and i have been given 3 WMA files.
My question: What is the best way to play these wma files? Convert them to another format?
And when i converted them to the "correct" format how do i know when its finished playing so i can play the next song? And how will i even load the song. Thanks!
PeejAvery
June 23rd, 2009, 01:23 PM
Your best shot is to work with MP3s. There is already quite a support base for that and flash. While you're at it, check out some Flash + MP3 tutorials.
http://theflashblog.com/?p=228
wigga
June 24th, 2009, 06:31 AM
thanks alot.
i already made the music played, the next thing i need to do is make it play in random order and every song has to be played before it can be played again. i was thinking about making a shuffled array that contains the index of the song to be played.
var xmlPlaylist:XML;
var iCurrentSong:int;
var sCurrentSong:Sound;
var cCurrentSong:SoundChannel;
var txtSongTitle:TextField;
var urlLoader:URLLoader = new URLLoader(new URLRequest("jukebox.xml"));
urlLoader.addEventListener(Event.COMPLETE, function(e:Event):void
{
xmlPlaylist = new XML(e.target.data);
urlLoader = null;
iCurrentSong = 0;
txtSongTitle = new TextField();
stage.addChild(txtSongTitle);
txtSongTitle.autoSize = TextFieldAutoSize.LEFT;
PlayCurrentSong();
});
function PlayNextSong():void
{
++iCurrentSong;
if(iCurrentSong >= xmlPlaylist.SONG.length())
iCurrentSong = 0;
PlayCurrentSong();
}
function PlayPrevSong():void()
{
--iCurrentSong;
if(iCurrentSong < 0)
iCurrentSong = xmlPlaylist.SONG.length() - 1;
PlayCurrentSong();
}
function PlayCurrentSong():void
{
txtSongTitle.text = "<font color=\"white\">" + xmlPlaylist.SONG[iCurrentSong].@TITLE + "</color>";
sCurrentSong = new Sound(new URLRequest(xmlPlaylist.SONG[iCurrentSong].@FILE));
cCurrentSong = sCurrentSong.play();
cCurrentSong.addEventListener(Event.SOUND_COMPLETE, function(event:Event):void
{
PlayNextSong();
});
}
silverlady26
July 6th, 2011, 08:37 AM
Your best shot is to work with MP3s. There is already quite a support base for that and flash. While you're at it, check out some Flash + MP3 tutorials.
flash mp3 player (www.spencer-tech.com/my_scripts/mp3_player)http://theflashblog.com/?p=228
I consider that the best way is to use someone's tutorial. For sure it may seem that the easiest option is to use ready script which is done instead of you but it will not teach you anything.
silverlady26
July 11th, 2011, 07:48 AM
Every flash mp3 player has a shuffle function but that's shuffle only for users, every player has a particular algorithm like to play 1 then 11th then 21 and this way.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.