Da11aS
Da11aS

Reputation: 465

Javascript play() Function not working in ie11

I am trying to use onclick to call a function and play a file however the file does not play in ie11, plays fine in Chrome and Firefox.

Here is the code

  function play1(){
       var audio1 = document.getElementById("audio1");
       audio1.play();
  }
  function play2(){
       var audio2 = document.getElementById("audio2");
       audio2.play();
  }
<div class="audiobuttons"><a class="btn btn-primary" onclick="play1()">Play Example <i class="icon-white icon-play"></i></a></div><br /><audio id="audio1" src="training/example7.wav" ></audio></div>
<div class="audiobuttons"><a class="btn btn-primary" onclick="play2()">Play Example <i class="icon-white icon-play"></i></a></div><br /><audio id="audio2" src="training/example8.wav" ></audio></div>

Upvotes: 0

Views: 1326

Answers (2)

Ian Holden
Ian Holden

Reputation: 331

As @adeneo correctly mentions, IE11 does not support WAV files. I had this issue and found that a simple file conversion to MP3 files solved my issues. It has much greater support.

For more info, see here: https://caniuse.com/#search=mp3

Upvotes: 0

adeneo
adeneo

Reputation: 318352

Internet Explorer 11 does not support .wav files, it was added in Edge

enter image description here

http://caniuse.com/#feat=wav

Upvotes: 3

Related Questions