CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    103

    flash music player?

    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!

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: flash music player?

    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
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2009
    Location
    Netherlands
    Posts
    103

    Re: flash music player?

    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.

    Code:
    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();
    	});
    }
    Last edited by wigga; June 24th, 2009 at 06:37 AM.

  4. #4
    Join Date
    Jul 2011
    Posts
    2

    Re: flash music player?

    Quote Originally Posted by PeejAvery View Post
    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 playerhttp://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.

  5. #5
    Join Date
    Jul 2011
    Posts
    2

    Re: flash music player?

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured