Flash production simple MP3 player

Source: Internet
Author: User
Tags setinterval

Effect Demo:

Click here to download the source file

First create a few buttons, put in the first frame, click on the button on the button to write the following code:

On (release) {
Create a function so that the music file is loaded to 25% before it starts playing, otherwise it will be loaded from the Web when the card.
function Zairu () {
if (b>=25) {
Mysound.start (0,10);
Clear if loaded to 25%.
Clearinterval (poll);
}
}
Poll=setinterval (zairu,100);
Yinyue ("You want to load the MP3 address");
}



Back to the main scene, create 2 dynamic text, the variable name is TXT1,TXT2,TXT3,

function Yinyue (name) {
Establish sound objects for easy control of sound
Mysound=new Sound (this);
Load Sound
Mysound.loadsound (name,true);
Stop the sound first, or the sound will be loaded to play automatically when you start the decompression program.
Mysound.stop (name);
}
function loading () {
Loaded sound size
L=mysound.getbytesloaded ();
Total Sound Size
M=mysound.getbytestotal ();
B=int (l/m*100);
txt1=b+ "%";
Txt2=int (l/1000)/1000+ "M" + "/" +int (m/1000)/1000+ "M";
Played sound time
Time=int (mysound.position/1000);
Total sound Time
Time2=int (mysound.duration/1000);
S1=time;
if (s1<10) {
s1= "0" +S1;
}
Txt3= "Played:" +s1+ "seconds";
Loading21.loading3._xscale=b;
Set the volume size of the sound,
Mysound.setvolume ((huakuai2.huakuai._x+50) *2);
}
Timer trigger time is 100 milliseconds, so the variables set above are constantly updated
SetInterval (loading,100);

Create playback, pause, fast-forward, rewind button write as

On (release) {
This.mysound.start (this.mysound.position/1000,1);
}
On (release) {This.mysound.stop ();}
On (release) {
This.mysound.start ((this.mysound.position/1000) +10,1);
}
On (release) {
This.mysound.start ((this.mysound.position/1000) -10,1);
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.