Link to home
Create AccountLog in
Avatar of ray-solomon
ray-solomonFlag for United States of America

asked on

Flash can play mp3, but can it play wav?

I have 2 example pages using the same code but calling on different audio files.
One is an mp3 and the other is a waveform.

The mp3 works, but not the wav.
http://www.pocourl.com/mp3.php
http://www.pocourl.com/wav.php

How can I get the wav to work properly with flash without importing it into a swf container?

or if you can think of another cross-browser/platform way, then let me know.

Thanks.


Below is the actionscript I am using:
// Action script...
 
// [Action in Frame 1]
var SoundLoader = {};
SoundLoader.loadSound = function (variableName, oldVal, newVal)
{
    var _loc1 = this;
    mySound = new Sound();
    mySound.loadSound(newVal, true);
    _loc1.createEmptyMovieClip("loader_mc", 5);
    loader_mc.onEnterFrame = function ()
    {
        var _loc1 = this;
        percentage = Math.round(mySound.getBytesLoaded() / mySound.getBytesTotal() * 100);
        if (percentage >= 100)
        {
            _loc1._parent.mySound.start();
            _loc1.onEnterFrame = null;
            unloadMovie(_loc1);
        } // end if
    };
};
_root.watch("playSound", SoundLoader.loadSound);

Open in new window

Avatar of blue-genie
blue-genie
Flag of South Africa image



flash player only supports PCM WAV file format. - one way to test if your wav is in the right format, import it into a swf file and if you get an "unrecognised file format" error - then your wav file is the problem.

any specific reason you want it wav? you can convert it to mp3, or is it very dynamic?
attach the wav file, if so.
Avatar of ray-solomon

ASKER

All wav files I am using are in pcm format.
This is required for a third-party api in which I am already using successfully.

All wav audio files meet these criteria for the api:
Sample size: 16 bit
Sample rate: 8 kHz
Channels: mono
Format: PCM
Bit Rate: 128kbps (normally this, but not required)

I wrote a script to check the required criteria of the audio file upon upload.

Now, I am trying to integrate a simple audio preview so clients can quickly hear it.
I used the same code as I used for mp3 from my other web site, but it did not work for wav files.

Is there different action script code I should be using?
ASKER CERTIFIED SOLUTION
Avatar of CyanBlue
CyanBlue
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I ended up using html embed code for windows media player.
It was the only option I had.