A Flash Developer Resource Site


Turn Flash in Desktop App or Widget. Win & Mac.


FreeSpin3D – 3D in a Flash. Real-Time 3D for Developers and Designers.


World's Favorite Flash Tool 200,000 users and growing!


Create Flash animations without coding with FlashEff


Gartner Whitepaper: How IT Management Can "Green" the Data Center. This Gartner research provides IT managers with an outline of the trends affecting datacenters & offers strategies with which to address these changes.

Storage Networking , Part 1
eBook: A storage network is any network that's designed to transport block-level storage protocols. But understanding the ins and outs of networked storage takes you deep into several of protocols. This guide covers SANs, Fibre Channels, Disk Arrays, Fabric, and IP Storage. »

Storage Networking 2, Configuration and Planning
eBook: Picking up where Part 1 left off, Part 2 of our look at storage networking examines configurations for SAN-attached servers and disk arrays, and also includes a look at the future of IP storage. »

Storage Management Costs in the Enterprise: A Comparison of Mid-Range Array Solutions
Whitepaper: Many factors contribute to the ownership cost for enterprise storage. These include (but are not limited to): physical capacity relative to physical space requirements, performance capacity for data transfer and system reaction time, software maintenance and updates, expandability and flexibility, and much more. »

Storage Is Changing Fast  Be Ready or Be Left Behind
PDF: The storage landscape is headed for dramatic change, thanks to new technologies like Fibre Channel over Ethernet (FCoE), pNFS, object-based storage and SAS that will affect everything from NAS and SANs to disk drives. Get the knowledge you need to make the most of your storage environment, now and in the future. »

HP StorageWorks EVA4400
Demo: Dont settle for an expensive and complex array that lacks functionality. The HP StorageWorks EVA4400 delivers virtual storage with enterprise class functionality at an affordable price. »

Featured Flash FLA
Gallery Downloads 11194 Flash Movies | 7 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Kaushik Basak
» Title: Head
» Description: This is another example of basic keyframe animation.
» More by Kaushik Basak


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6608 Flash Sites | 4 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: eigoMANGA STUDIOS
» Comments: eigoMANGA STUDIOS is a business to business consulting firm that develops anime and manga projects for other business organizations


Random Links | Add your own Flash Related Links
Flash Tutorials 1170 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create Graduation Photo Slideshow to Cherish School Memories
» Making movieclips point at the mouse
» Create Flash slideshow for Youtube
» Move a sprite with the keyboard
» Convert FLV to AVI video with DIVX codec to author a desired video with your favorite FLV movie!
» Flash Video Conversion Guide for Apple TV
» How to Convert FLV to iPhone movies
» Convert FLV(Flash Video) video to Cell Phone
» Convert FLV to AVI with XviD video codec to enjoy a DVD quality video with half of its size
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Web Designer
Aquent
US-NJ-Parsippany

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Utilities

Categories make your own mp3 player
Author: roozbeh afrasiabi(black_death) | Website: none |

 
Page 1
1

Make your own MP3 player using Flash MX :
Version 2.0


Introduction:

One of the best features of Flash MX is its ability to download mp3 files directly into flash player, before the release of flash MX developers had to import mp3 files into their projects and this made handling such files very hard. But now with the loadSound() function you can easily load mp3s and choose the method flash player downloads them.
There are basically two methods you can use to load your mp3s into flash player:

1.event
2.streaming


According to the method you select flash MX gives youdifferent options for handling the file.Event sounds have to be downloaded before they can be controlled, streaming sounds play while they are being loaded, so flash player gives you full control over event sounds and less options for handling streaming sounds.

When you load mp3s as event sounds you can use all commands for handling sound objects that actionscript offers, on the other hand when you load mp3s as streaming sounds you are only given the ability to stop, play or set volume-pan of the music file .


How it is done:

First of all run flash MX and create an empty project. Choose your desired document size and background color.

This mp3 player requires some buttons, you can make your own buttons or Use the buttons flash stores in the common libraries.

We will organize our scripting by using functions for the most part
of the MP3 player.
All functions are placed in the first frame (main scene).

Functions:


play:


function playa() {
if (playing!=true) {
mysound=new Sound();
if (url!=null) {
mysound.loadSound(url+".mp3", false);
mysound.start((_root.pos)/1000,1);
if (mysound.duration!=0) {
playing=true;
}
} else {
}
}
}

Note: You can not use play as the function name, flash already has
A built in function with that name. In general avoid naming your
Functions with names that are already used by flash.

This function will simply load the mp3 file from the path (URL) you have provided if the URL exists.

Note: you can use an input text box to get the URL from the user.

Note:_root.pos is a variable that stores the file position

If the URL value is null you can use the else command to force the
user into inputting a valid path or file name.

Stop:

function stopa() {
_root.pos=0;
mysound.stop();
playing=false;
}


The _root.pos=0 sets the pos value to zero so if the user calls the
playa function the file will be played from the beginning.

Pause:


function pause() {
if (playing) {
_root.pos=mysound.position;
mysound.stop();
playing=false;
}
}


This function pauses the sound and stores the position value in the
pos variable.(The pos value will be used when the user calls the
playa function, in this way when the music is played again it starts
from the position where it was stopped before)

Copy/paste all these functions to the first frame (on the main scene)
Of your project.


Forward/Rewind:

Create an empty movie clip and place the following scripts inside the
first frame of the movie.


if (_root.rw) {
if (_root.playing) {
pose = int((_root.mysound.position)/1000)-1;
_root.mySound.stop();
_root.mySound.start(pose, 1);
}
}


if (_root.fw) {
if (_root.playing) {
pose = int((_root.mysound.position)/1000)+1;
_root.mySound.stop();
_root.mySound.start(pose, 1);
}
}

Now select the next frame and convert it to a keyframe this will make a loop.

Mute:

Create a global sound object that can control the overall sound volume:

globalvolume = new Sound();

Place the above script in the first frame(main scene) we will use a button to
control this object.
Buttons:


play/pause/stop:

Just use the buttons you made before to call these functions .

Example:

on (press) {
pause();
}

forward/rewind/mute:

Copy/paste the following scripts to the buttons you have made
before.


Forward:

on (press) {
fw = 1;
}
on (release, releaseOutside, rollOut, dragOut) {
fw = 0;
}

Rewind:

on (press) {
rw = 1;
}
on (release, releaseOutside, rollOut, dragOut) {
rw = 0;
}

Mute:

on (release) {
if (_root.globalvolume.getVolume()>0) {
_root.globalvolume.setVolume(0);
} else {
_root.globalvolume.setVolume(100);

}
}


Counters:

Add these to the first frame(main scene) of your movie:

playing=false;
var pos=0;

These will set the default values for playing and pos.

Volume&pan:

you can use any fader to control the volume-pan of your mp3.

Note: If you can not handle making a fader use the faders in the common
libraries of flash MX.
Commonlibraries>>buttons>>Knobs&faders>>fadergain


And that’s it you have made your own MP3 player and it works fine.
You can now use your knowledge of action script to make this player as
complicated or as simple as you want.

1

» Level Advanced

Added: : 2002-12-12
Rating: 5.87 Votes: 143
Hits: 1180
» Author
none
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers