Version

menu_open
Wwise SDK 2019.1.11
JavaScript, In browser - WAMP

Initializing the project

Note: This example requires npm to be installed (installed with Node.js) and Git for installation of Bower packages. Supported browsers are Google Chrome, Mozilla Firefox, and Opera.

Run the following commands from the sample directory, <Wwise installation path>/SDK/samples/WwiseAuthoringAPI/js/hello-wwise-web-wamp, to install dependencies.

npm install -g bower
bower install autobahn

Project Code

The sample file, index.js in the hello-wwise-web-wamp sample directory allows to connect to the Wwise Authoring API.

var showMessage = function(message){
document.getElementById("message").innerHTML = message;
}
function onBodyLoad() {
// Create the WAMP connection
var connection = new autobahn.Connection({
url: 'ws://localhost:8080/waapi',
realm: 'realm1',
protocols: ['wamp.2.json']
});
// Setup handler for connection closed
connection.onclose = function (reason, details) {
showMessage('wamp connection closed');
return true;
};
// Setup handler for connection opened
connection.onopen = function (session) {
showMessage('wamp connection opened');
// Call getInfo
session.call(ak.wwise.core.getInfo, [], {}).then(
function (res) {
showMessage(`Hello ${res.kwargs.displayName} ${res.kwargs.version.displayName}`);
},
function (error) {
showMessage(`error: ${error}`);
}
);
};
// Open the connection
connection.open();
}

The sample file, index.html, in the hello-wwise-web-wamp sample directory is a simple webpage which uses the previous script to connect to the Wwise Authoring API and renders the output message.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello Wwise</title>
<script src="node_modules/autobahn-browser/autobahn.min.js"></script>
<script src="../../../../include/AK/WwiseAuthoringAPI/js/waapi.js"></script>
<script src="index.js"></script>
</head>
<body onload="onBodyLoad()">
<div id="message">
Not connected.
</div>
</body>
</html>

Running the project

Double-click index.html to open in a supported browser.

If the Wwise Authoring API successfully connects to Wwise, you should see the following output:

Hello Wwise 20??.?.?

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise