Getting SAP ITSmobile bgsound support on Enterprise Browser

Edward Correia -
3 MIN READ

By Sabir Valappil Thattath

 

The ITSmobile system from SAP plays various sound files to notify a user whether a server transaction was a failure or success. This is implemented by presenting the HTML tag to the browser. Though the element was once used for playing a sound in background, the tag is now obsolete and treated as a non-standard element; it is presently supported only by IE engines.

 

This creates a problem for SAP users when running existing SAP applications on standard HTML5 browsers. A recent customer interaction involved the need to run an application on a Windows Mobile/CE device with the webkit engine. As expected, the tag would not function on that HTML5 webkit engine, so we solved the problem by developing a workaround.

 

On devices running Android, there's a way to solve this problem without a special workaround and without modifying the SAP application. The answer come with DOM Injection and some JavaScript. Our solution parses the HTML document to replace the tag file with an HTML5-compatible audio tag. We put HTML element-replacing logic to a JavaScript file and included that JavaScript file in the CustomDOMElements list. For complete details, please refer the DOM Injection docs.

 

Below is the script that will be injected and executed once the DOM is ready on the webview:

 

function playBgSound()

{

//get list of bg sound tag, ideally any page will hold one sound file only :-)

  var bgs = document.getElementsByTagName('bgsound');

 

   for (var bgElementIndex=0; bgElementIndex

   {   

    

      //get the url of the sound file

        var bgSrc = bgs[bgElementIndex].getAttribute("src");    

      //create a audio HTML element supported by webview

       var audioTag = document.createElement("AUDIO");

      audioTag.setAttribute("src",bgSrc);//set sound file url

      audioTag.setAttribute("autoplay","true");//set autoplay to true  

      document.body.appendChild(audioTag);//insert to document body

   }

 

}

playBgSound();

 

Any custom JavaScript files to be injected to DOM have to be referenced inside the CustomDOMElements file (in our case, the file name is mytags.txt) as shown below:

 

profile

Edward Correia

Please register or login to post a reply

Replies