Guest User

Guest User

  • Tech Writer
  • 31
  • 22.7k

audio files overlapping.

May 15 2017 3:23 AM
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <meta charset="utf-8" />  
  5.     <title>RailwayAnnouncement</title>  
  6. </head>  
  7. <body>  
  8.     <input id="TrainNumber" type="text" />  
  9.     <input id="Submit" type="button" value="Submit" onclick="submit();" />  
  10. </body>  
  11. </html>  
  12. <script>  
  13.     function submit() {  
  14.         var TrainNumber = document.getElementById("TrainNumber").value;  
  15.         var length = TrainNumber.length;  
  16.         for (var counter = 0; counter <= length - 1; counter++)  
  17.         {  
  18.             var trackNumber = TrainNumber[counter];  
  19.             var audio = new Audio(trackNumber+'.mp3');  
  20.             audio.play();  
  21.         }  
  22.     }  
  23. </script>  
Here is what I did. Audio files are overlapping. But I want them to play one after another. Help me with suggestions.