Integrating JS Decoder

How to "audio-enable" your web-content with the Intrasonics JS Decoder


The steps below outline preparing your audio and video content and how to integrate Intrasonics JS Decoder to your website.


1.  Obtain a Token

A token specifying which audio-triggers should be responded to is required to activate the JS Decoder.

The token included in the download from this site uses non-exclusive demonstration triggers and is prohibited for use in production.

To use the JS Decoder on your own website you must license unique commercial audio-triggers from Intrasonics. Please see the licensing page for more information.

Once you have licensed some commercial audio-triggers, you will be able to create a token via Intrasonics Portal, the online gateway to our products and services.

2.  Encode Your Content

The JS Decoder responds to audio triggers encoded in audio and video content.

Your Portal credentials gain you access to Intrasonics Cloud Encoder to upload and watermark your audio and video content with your exclusive audio-triggers.

3.  Add Core Decoder Files

With your token and some media encoded with your exclusive audio-triggers, you can begin to integrate the Intrasonics JS Decoder...

  1. Download the JS Decoder ZIP Archive
  2. Unpack and upload your token and JS Decoder script to your server:
    intrasonics.js
  3. Add the following script tag to your HTML in the <head> section of your document.
    <script src="intrasonics.js" async></script>

4.  Configure JS Decoder

The Intrasonics JS Decoder can only be started once a valid token has been loaded. A Promise chain is used to notify your web-content when this has happened.

Event Listeners are sections of your code that listen for and respond to the different events emitted by the JS Decoder.

Add this code before the closing </body> tag of your HTML page to load the token, start the JS Decoder and respond to the events raised:

<script language="javascript">

window.onload = function() {
   intrasonics.on("action", function(action){
       // show the received codeword
       alert(action.id);
    });
    intrasonics.on("error", function(err){
        // show the error received
        alert(err.msg);
    });
    intrasonics.loadToken( "MyToken.ist")
        .then( () => intrasonics.start() )
        .catch( msg => {
            console.log( "Error:", msg );
        });
};

</script>

See a list of all the types of events raised by the JS Decoder in the API Documentation.

5.  Test in a Browser

Open your web page in a compatible browser and play your encoded media. If you've followed the steps above you will see an alert dialog appear for each detected audio-trigger.

You're done!

Now edit the response handler code to meet the specific requirements for your web-content.

Troubleshooting

If the JS Decoder isn't working for you, please trace your steps against the instructions above.
If you need further assistance in getting your codewords to be detected, please contact us for support.