I am having problem in playing mp3 sounds in my website. In a normal page I use an embed tag to play a mp3 file that uses a swf file to play the sound. Now I want to play the sound on a javascript event, eg when a button is pressed, or when user types in a letter. I tried to use a Javascript function that is called when the event occurs, I couldnot figure out how to play a mp3 file using that function. Please help!!
Asked
Active
Viewed 123 times
1 Answers
0
You can do this:
<div id="container"></div>
<script type="text/javascript">
jwplayer("container").setup({
file: "/videos/bunny.mp4",
flashplayer: "jwplayer/jwplayer.swf",
image: "/thumbs/bunny.jpg",
height: 270,
width: 480
});
</script>
<ul>
<li><a href="#" onclick="jwplayer().play();">Toggle the playback</a></li>
<li><a href="#" onclick="jwplayer().setMute();">Toggle the audio</a></li>
<li><a href="#" onclick="jwplayer().stop();">Stop playback</a></li>
</ul>
Read more here

Anshu
- 7,783
- 5
- 31
- 41