...

View Full Version : Flash and sound: Loading only a part of an mp3. Is this possible?



tagnu
01-24-2009, 10:19 AM
Hi all,

I have an mp3 file of 50 MB size, which has 4 songs combined.

For example, song1 plays from 00:00:00 (hour:minute:seconds) to 00:05:00 and other songs in the following order.
00:05:01 - 00:10:00 - Song2
00:10:01 - 00:14:00 - Song3
00:14:01 - 00:20:00 - Song4

What I'm looking for is to load the each songs separately.

Say, just to load Song 3 from 00:10:01 - 00:14:00, I use the following code.


var test_sound:Sound = new Sound();
test_sound.loadSound("http://localhost/test/combined-songs.mp3",true);
test_sound.onLoad = function ():Void{
test_sound.start(600);
};



The problem is, it loads everything and then plays from the 600th second.


But if I remove the onLoad event and make it like:


var test_sound:Sound = new Sound();
test_sound.loadSound("http://localhost/test/combined-songs.mp3",true);
//test_sound.onLoad = function ():Void{
test_sound.start(600);
//};


it doesn't skip the first part :(

Is there a way to load only the required data?

Thank you.

gnomeontherun
01-24-2009, 12:08 PM
Well you have to load the whole mp3 I believe. Perhaps it would be easier to cut out the extra stuff you don't want and order it correctly? This would be the best solution.

Search for audacity for a great free editor.

Otherwise, is this all of the code? Something is missing that would help figure this out, but it has something to do with play(600);, which is the marker at which position to start playing the audio. Also your filename says 'combined', so are they all together or are you loading 5 song files?

tagnu
01-24-2009, 01:33 PM
I have a single file (combined-songs.mp3) which actually has 5 songs combined.

I'm trying to figure out a way to play each songs without making separate .mp3 files. (using audacity or any other sound editor)

This is all the code as of now :)

The following code is to play the file from 10th minute, which is the second song.

play(600);

Hope I didn't confuse.

gnomeontherun
01-24-2009, 04:12 PM
Is that all of the code, or are you using buttons to have it play?

I think you could to use sound cues in order to have the files know when the songs were at a certain point. Otherwise you could have a listener that listens for when the sound is at a certain point and stops it.

http://www.adobe.com/devnet/actionscript/articles/cue_points_audio.html
http://livedocs.adobe.com/flash/9.0/main/00000291.html

tagnu
01-26-2009, 01:51 PM
Yes, that's all the code I have. No buttons as of now, I'm just testing the possibility.

Thank you for the links. I'll check them and get back.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum