Hello and welcome to our community! Is this your first visit?
Register
Results 1 to 2 of 2
  1. #1
    Japanologist Wilio's Avatar

    Join Date
    Dec 2005
    Location
    Somewhere in time
    Posts
    5,561

    Music player Basic tutorial.

    Yay! Please don't comment too much on the example(design)

    This tutorial explains how to make a stream music player for your website.
    For this tutorial, you absolutely need:
    Flash with actionscript 2.0 support.
    Tool that can help:
    Ftp Client(in example: filezilla).

    Yes, it might sound easy. You might think: make a play button add music and tada I’m like donez!
    Well, what if the songs you want to play aren’t actually in the swf but outside.


    Stream musicplayer can help you have a low flash size(like 3kbps) that
    Supports up to many song as you want. But I recommend not more than 5 because
    Songs can kill your bandwidth(I think)


    First you need to organize your work:
    Layer, buttons, script layer…etc.
    As in this example:

    This is two variables important:
    Code:
    Music = new Sound(); //the variable music is set to new Sound
    	Music.loadSound("", false);
    //load sound in the “ “(add later) [/code]

    You may wonder what’s the false? Simple if it’s set to true, the song will play while its loading,
    If its false, it has to load completely before able to play.

    Now on the Actionscript layer(that I called streamer), write:
    Code:
    Music = new Sound();
    complete = 0;
    Music.loadSound("", false);
    onEnterFrame = function () {
    	downloaded = Music.getBytesLoaded();
    	total = Music.getBytesTotal();
    	if (downloaded != total) {
    		_root.song = "downloading";
    	} else {
    		complete = 1;
    		_root.song = ""
    	}
    };
    things to remember:
    the operator != means is not equal to
    the operator = doesn’t mean equal, it mean “is set to”
    Also I’ll explain this code:
    Two variables are included:
    Downloaded: wich is set to the bytes that is loaded.
    And Total wich is set to the total file size(in bytes)

    So there is a if statement that says:
    If downloaded is not equal(!=) to total.
    The text will be downloading.
    Else it will show the secret song title
    And complete will be equal to 1.

    Now test it, and you will see two errors:
    -Can’t find the url blablabla(completely normal)
    And: there is no damn text.. (Why!!!)
    Well read this step:


    Now click on the text box and open propreties now write a variable:
    Song and set to multiline:

    Test your movie.
    And you should see: Downloading…

    PART 2
    Yes part 2. Now get something like a ftp client(or whatever to host on your site)
    For example you want to host in the index.
    Make a new folder called music from the root folder(the first of the first)

    So now in this folder you’ll put the song you want..
    So put the song you need..
    As for me I’ll put a song from U2 called Pride.
    So after this step.. copy the song name in where you should:
    Code:
     Music.loadSound("music/U2 - Pride (In The Name Of Love).mp3", false);
    and here to show music title:
    Code:
     else {
    		complete = 1;
    		_root.song =" U2 - Pride (In The Name Of Love)" //joo can play the song
    	}
    Yes this mean we are getting back to flash.
    Now name the instance name of your play button: play.
    And in the script layer, write:
    Code:
    play.onRelease = function() {
    	if (complete == 1) {
    		Music.stop();
    		Music.start();
    	}
    };
    you may wonder why there is a stop and start. Well this is a anti over song I made.
    Like the song won’t go over when play is pressed again. It will stop and replay.(so no over song shit madness)
    You may wonder why it’s not direct in the button script, that’s cause It doesn’t work(don’t ask me why)

    Name the stop button: stop(instance)
    Code:
    stop.onRelease = function() {
    	Music.stop();
    };
    the complete script is:
    Code:
    Music = new Sound();
    complete = 0;
    Music.loadSound("music/U2 - Pride (In The Name Of Love).mp3", false);
    onEnterFrame = function () {
    	downloaded = Music.getBytesLoaded();
    	total = Music.getBytesTotal();
    	if (downloaded != total) {
    		_root.song = "downloading";
    	} else {
    		complete = 1;
    		_root.song = "U2 - Pride (In The Name Of Love)";
    	}
    };
    play.onRelease = function() {
    	if (complete == 1) {
    		Music.stop();
    		Music.start();
    	}
    };
    stop.onRelease = function() {
    	Music.stop();
    };
    I guess the code is obvious…
    Now place your swf in root folder
    And try…
    Ex:
    Music player!
    Now you might say: Holy fuck, big? Yeah it’s normal.
    But on your page you should write:
    Code:
    <object width="300" height="60">
    <param name="movie" value="mus.swf">
    <embed src="mus.swf" width="300" height="60">
    </embed>
    </object>
    Change width, name and stuff like that with your own and wuzam!

    http://tutofromheaven.xmgfree.com/you.html



    Any questions or problem with the turorial. Say it here!

  2. #2
    Enthusiast


    Join Date
    Mar 2006
    Location
    Nueva York
    Posts
    2,481
    Very nice. I already know how to do this, and your example was ugly, but if someone cares they'll make theirs look good. hahah.

    It's nice, keep up da AS shiz.

    Animations - Do not Click Me - And Me Neither
    You have good sight, or good ctrl+c, ctrl+v skills. Also your computer might be set to %500 magnification.


 

Posting Permissions

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