Question

I need to play a WAV file on an HTML page. IE doesn't support WAV files with the HTML5 audio tag, so especially for that case I am using the embed tag:

<EMBED id="audioPlayer" type="audio/wav" src="xx.wav" loop=false>

I have managed to play, pause, and stop the audio as well as seek it using javascript, for example:

document.getElementById("audioPlayer").currentposition = 0;

I want to control the player volume, and fail to find any reference as to how it can be controlled. I have tried setting volume property, and it did not have any affect.

How can I control the volume using javascript?

Was it helpful?

Solution 2

Hoping this will help others, since I could not find any help on this..

I finally solved this issue by using the object tag instead of embed. Using the object tag I could access the volume and mute properties.

<object type="audio/wav" id="audioPlayer" class="origPlayer" >
    <param name="src" value="put the audio URL here">
</object>

OTHER TIPS

audio/wav is not the correct MIME type for .wav files: audio/x-wav is.

This MIME type mismatch is probably the reason it isn't playing with <audio>.

Try setting the correct MIME type on your <audio> tag and it should work.

Failing that, convert the file to MP3. Not only will it increase browser support, but it will result in a smaller file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top