Calling play() with a startPosition, and then calling stop() on the 
SoundChannel instance will work fine as long as the timing doesn't need to be 
too precise, and you don't mind slight glitches (pops or clicks) at the start 
and end.

If you want sample accurate start/end times, you can use a couple of new 
capabilities in FlashPlayer 10, namely the ability to extract audio sample data 
from an mp3, and the ability to send arbitrary audio data to the output in 
response to a SampleData event. Using these APIs, plus lots of other code, you 
can do some pretty sophisticated audio processing (see for example, 
http://labs.sonoport.com/audiostretch/).  In response to the original query, 
using Sound.extract and SampleData event, plus a bit of additional code, you 
could play an mp3 from any sample position to any sample position, and even 
apply a smooth ramp-in and ramp-out to prevent any glitching.

Andre Michelle's blog has some great examples of how to use the FP 10 audio 
API, for example:
http://blog.andre-michelle.com/2010/playback-mp3-loop-gapless/

-Gerry Beauregard

Lead Software Architect
Sonoport.com

On 2010-05-11  , at 03:45 , Glen Pike wrote:

> Hi,
> 
>  The Sound "play" method returns a SoundChannel instance, which you can call 
> stop() on to stop the sound.
> 
>  Glen
> 
> Jim Andrews wrote:
>> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html
>>  
>> 
>> The above URL is the main page to acquaint yourself with concerning the 
>> Sound class in ActionScript 3.0, apparently.
>> 
>> If you scroll through it, you'll see some example code.
>> 
>> You'll also see the 'play' method under 'Public Methods' and, in the 
>> documentation of the 'play' method, you see that it takes a 'startTime' 
>> parameter. This one is what you use to start the sound not at the beginning 
>> of the Sound.
>> 
>> The 'play' method, in Director, also can take an 'endTime' parameter, and 
>> there is a 'stop' method. Not in Flash, though. Also, in Director, there is 
>> an 'elapsedTime' property for the sound. Not in Flash, though.
>> 
>> So if you want to end the sound before it ends, erm, I guess you have to use 
>> a timer to monitor where we are in the playing of the sound and then end the 
>> sound how? erm by using the 'close' method? Which also cancels any 
>> downloading.
>> 
>> ja
>> http://vispo.com
>> 
>> 
>> 
>>> Say I have a sound that lasts 1.7 seconds. Is there a way to control what 
>>> plays - for example. if I want to start it .4 seconds in and stop it .2 
>>> seconds before the end....
>> 
>> _______________________________________________
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> 
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to