htmlaudiosap-web-ide

Playing audio in SAP Web IDE



i am trying to play a mp3-file in the SAP Web IDE but can't get it working.

    var audio = new Audio("sound/beep.mp3");
    audio.play();

It does not seem that the IDE is even loading the soundfile.
Do i have to add something in the preload config?


Solution

  • I found a solution on SCN

    They add the audio tag in the index.html:

    <body class="sapUiBody">  
      <div id="content"></div>  
      <audio id="idErrorSound">  
        <source src="audio/ErrorSound.mp3"></source>  
      </audio>  
    </body>  
    

    and then load it by the given id like this:

    function playErrorSound() {  
        var audio = document.getElementById("idErrorSound");  
        audio.play();  
    }