View Full Version : Can Actionscript play .wav file located on the client side?
janice_2k
June 21st, 2004, 04:13 AM
Dear gurus and members,
I am newbie in Flash MX 2004 and Actionscript. Hope that someone out there would share some knowledge and expertise in these areas. I would like to know whether is it possible that Actionscript play .wav files that are stored on the client side? If yes, how? Otherwise, what are the alternatives to enable playback of wave files on the user's computer? I plan to create a button that will playback pre-recorded speech(mp3 format stored in the server) as well as user recorded speech (.wav format stored on the client side after user recorded the speech). How can I do so? I would want to make it away that it appears like a Q&A conversation session between the computer (mp3) and user (recorded wave). Any suggestions or ideas are highly appreciated. Hope to hear some reply soon.
Thanks in advance,
Janice
¬...
June 21st, 2004, 01:13 PM
stop();
el_objeto_sonido=new Sound();
el_objeto_sonido.loadSound("sound.mp3","false");
sonido_cargado=function(){
delete onEnterFrame;
el_objeto_sonido.start("",999);
el_objeto_sonido.setVolume(100);
trace("the sound is loaded");
}
onEnterFrame=function(){
bl=el_objeto_sonido.getBytesLoaded();
bt=el_objeto_sonido.getBytesTotal();
perc=int((bl/bt)*100);
trace(perc);
if(bl==bt){
sonido_cargado();
}
}
with these functions you can load a .mp3 file and see the loading progress wich you can throw to a dynamic text field, the percentage is in the variable 'perc'
janice_2k
June 22nd, 2004, 04:04 AM
Hi ¬...,
Thanks for the reply, I would like to load a wav. file from the user's computer. Is there any way to do that as well? Do I need to include the path where the user save the wave file as well? Hope to hear some reply soon.
Thanks in advance,
Janice
Ordinathorreur
June 22nd, 2004, 11:57 AM
Yes, you will have to know the exact path to the wav file on the users computer. You could use an input text field for the user to specify where flash can find the file. This method is hardly idiot proof though, so users may start cursing your Flash movie for mistakes they made.
You could also use PHP or so to allow the user to upload their wav, that way it will be more idiot proof as the file will always be uploaded into the target directory that you specify. But it will use precious server space and bandwidth
janice_2k
June 30th, 2004, 04:38 AM
Hi there,
As I don't need to view the percentage of the loading, I have changed part of the codes. The following is the code I did for the button:
on (release) {
stopAllSounds();
PE14Conv1e = new Sound();
PE14Convle.loadSound("file:///c:/Program Files/Sound Recording/AudioRecorder/NewSong52211.mp3", true);
PE14Conv1e.start(0, 0);
}
I have placed the .mp3 file in the folder correctly but when I tested the movie and build swf file (without uploading to the server yet as there are some difficulties in uploading to my server these few days), it does not play the mp3.
I did almost the same method on another button that calls server side mp3 file. However, this one works fine when I tested:
on (release) {
stopAllSounds();
PE14Conv1d = new Sound();
PE14Conv1d.attachSound("PE14_1d");
PE14Conv1d.start(0, 0);
}
I have no idea how to solve the problem in playing client side mp3 files from the Flash button on my website. Looking forward t some reply soon.
Thanks in advance,
Janice
janice_2k
July 1st, 2004, 12:03 AM
Ok, this method works fine
on (release)
{
stopAllSounds();
mySound = new Sound();
mySound.loadSound("file:///c:/program files/sound recording/audiorecorder/newsong52211.mp3", true);
mySound.start();
}
It was my mistake previously. Anyway, How can I make it in such ways that it will play serverside mp3 and client side mp3 alternately from the beginning till the end? For example:Q1(server side mp3)-A1(client side mp3), Q2-A2, Q3-A3...etc? The file name is fixed as: audio# for server side & test# for client side. ('#' = number). I think there should be a var that will check for the number of mp3s from the server and assign the value to a loop to play the mp3s. I would very glad if you could help me as I have no idea at all about actionscript and the language. I am at total lost. Looking forward to some reply soon.
Thanks in advance,
Janice
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.