简体   繁体   中英

Audio not playing in Flash AS3

I've been trying to play an external sound file in Flash and failing miserably.

The code couldn't be simpler:

var s:Sound = new Sound();  
var req:URLRequest = new URLRequest(MovieClip(root).videoLink);  
var context:SoundLoaderContext = new SoundLoaderContext(3000, true);   
s.load(req, context);  
var my_channel:SoundChannel;  
my_channel = s.play(0);

videoLink is a string containing a valid link to a WAV file on the same server.

The problem with this code is, I can only run it while it's on a live server (the link is obtained from a MySQL database via XML), so I can't tell if any error when it's being run. Then again, I can't see how the above code can lead to any problems.

I've spent more than 2 hours trying different solutions. Any help would be greatly appreciated.

Andrey

Your sound file should be a mp3 , not a wav. try the same code with an mp3 version and it should play.

Check this article, for info on how to play wav files with as3
http://richapps.de/?p=97

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM