Welcome to WebmasterWorld Guest from 34.231.21.123

Forum Moderators: open

Message Too Old, No Replies

newbie audio question

adding audio using flash

     
10:13 pm on Oct 2, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:June 10, 2005
posts:78
votes: 0


Hi all,

I am extremely new to flash and would really appreciate some advice.

I need to add a clickable button to a website that plays an audio file that is 1.3mb

I have turned to flash because using the embed method it streams badly on dial up and the client wants it to work on both dial up and high speed.

Is there a way to do this in flash? If so how?

Many thanks in advance

1:15 pm on Oct 4, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


Firstly, 1.3Mb sounds like a very large file to be putting as an event on a site, unless you are streaming it or adding it for download.

You can use flash and preload it, although at that size this may take a while to load.

7:48 pm on Oct 4, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:June 10, 2005
posts:78
votes: 0


Hi,

yeah I thought 1.3mb was pretty large. Is there a way to stream it and preload some of it?

9:51 pm on Oct 4, 2005 (gmt 0)

Full Member

joined:May 29, 2005
posts:287
votes: 0


It it will play straight away, we use sound files larger than this all the time.

try this, its a simple 2 button movie clip start/stop 100 x 50 pixels, this code is on the actions layer on frame 1

The buttons have an instance name of play_btn and stop_btn you need to edit the two instances of "whatever.mp3" to suit.

(I appreciate this may be old code but it works fine)

-----------------------------------------------------

onLoad = function() {
if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
if(typeof this.createEmptyMovieClip == 'undefined'){
this._parent.createEmptyMovieClip('BS_music',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.music = new Sound(this._parent.BS_music);
} else {
this.createEmptyMovieClip('_music_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.music = new Sound(this.BS_music);
}
_global.Behaviors.Sound.music.loadSound("whatever.mp3",true);
};
stop_btn.onPress = function() {
stopAllSounds();
};
play_btn.onPress = function() {
if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
if(typeof this.createEmptyMovieClip == 'undefined'){
this._parent.createEmptyMovieClip('BS_music',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.music = new Sound(this._parent.BS_music);
} else {
this.createEmptyMovieClip('_music_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.music = new Sound(this.BS_music);
}
_global.Behaviors.Sound.music.loadSound("whatever.mp3",true);
};

-------------------------------------

10:22 am on Oct 5, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


Very nice code - thanks for that Richard_N!
7:41 pm on Oct 5, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:June 10, 2005
posts:78
votes: 0


Thanks for the code. It worked a treat - however I still had to use the lower quality mp3 at about 700kb for it not to break up when played on dial up connection.

I will definately use this code again. thanks

1:17 am on Oct 15, 2005 (gmt 0)

New User

10+ Year Member

joined:Oct 15, 2005
posts:2
votes: 0


I found a utility to convert mp3 files to swf files, and can embed them in my web page (used a forms menu and a bit of java scripting to use the embed command to drop it in a frame and loop, but have no idea other than that very basic level how to control the playing of those files.

If I want to stop the music playing, or get it to play one of the other available files (by using a javascript function to check if it's playing for example, and if it is not, to play the next file) can that previous code work (ie, is that java scripting)? Or is that previous code for using in some other software? I tried similar code in a fairly blank but functional web page, and it didn't do much for me.

Any help would be appreciated

11:36 pm on Oct 15, 2005 (gmt 0)

Full Member

joined:May 29, 2005
posts:287
votes: 0


No its actionscript and needs to be placed on the first line of the main timeline within the flash movie (in this example).

If your looking for a ready made flash music player just google it there a quite a few out on the web.

2:21 am on Nov 2, 2005 (gmt 0)

Full Member

10+ Year Member

joined:Mar 27, 2004
posts:276
votes: 0


I also have a problem with getting an audio file to fully load for dial up users. Unfortunatly I bought that wimpy button thinking it was just nwhat i needed, i even did the test before i bought and it worked great. The guy who made it and sells it never indicates it does not work for dialup and once payed for its yours. How would I open the code to add the coding from this topic to get it to also work on dial up. What program do i need to do this with
Pat
7:40 am on Nov 2, 2005 (gmt 0)

Full Member

joined:May 29, 2005
posts:287
votes: 0


The code I supplied is standalone code, just create a new flash file, add the buttons, give them instance names and asign the code to the first frame in the actions layer.
3:51 pm on Nov 5, 2005 (gmt 0)

Full Member

10+ Year Member

joined:Mar 27, 2004
posts:276
votes: 0


Thanks Richard for replying. I am even worse than a newby, I know nothing about how to code flash or even what program editor i can use for it other than Macromedia which is very expensive and I still dont know how to use it. The only thing I really understand and would be able to change as it is in the code is the name of the mp3. I know not being able to have samples play for dialup users is hurting sales also. I will keep searching thanks
Pat