Right now I am using this code to load an external mp3 file into my website:
var url:String = ''my file'';
var urlRequest:URLRequest = new URLRequest(url);
var sound:Sound = new Sound();
sound.load(urlRequest);
sound.play();
I am wondering if it is possible to add playback buttons (play, pause, stop) which control this external mp3 file from my site. And what code I would use to do that.
Thanks for you help!
Pausing an external mp3 fileare the buttons on the same timeline as the timeline that contains that code?
Pausing an external mp3 fileI haven't added any buttons yet. I am not sure where to put them.
you can put them anywhere you like as long as they have some relation to your swf.
it would be easiest if you put them on the same timeline as the timeline that contains the code you showed.
Ok, but my question is how do I link the buttons to my external mp3? Is there a code you can give me to do that?
the answer to your question depends on the location of the buttons. that's why i've been trying to find out where they will be placed.
Ok, I will put them in the same timeline as that code.
var url:String = ''my file'';
var urlRequest:URLRequest = new URLRequest(url);
var sound:Sound = new Sound();
sound.load(urlRequest);
var sc:SoundChannel=sound.play();
var startTime:uint=0;
playBtn.addEventListener(MouseEvent.CLICK,playF);stopBtn.addEventListener(MouseEvent.CLICK,stopF);
pauseBtn.addEventListener(MouseEvent.CLICK,pauseF);
function playF(e:Event){
sc=sound.play(startTime);
}
function stopF(e:Event){
sc.stop();
startTime=0;
}
function pauseF(e:Event){
startTime=sc.position;
sc.stop();
}
Thank you, but I added the code and the buttons with matching instance names and it is showing errors. ''access of undefined property sc.''...
Sorry, I'm really new at this.
I fixed it, sorry I just didn't have an instance name right. Thank you so much for your help!
replace your code with the code i gave in my previous message and retest.
Thank you so much for all of your help! Maybe now it'll be easier to figure out ''next'' and ''previous'' buttons.
Thanks again
you're welcome.
No comments:
Post a Comment