Version

menu_open
Wwise SDK 2018.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??.?.?

Cette page a-t-elle été utile ?

Besoin d'aide ?

Des questions ? Des problèmes ? Besoin de plus d'informations ? Contactez-nous, nous pouvons vous aider !

Visitez notre page d'Aide

Décrivez-nous de votre projet. Nous sommes là pour vous aider.

Enregistrez votre projet et nous vous aiderons à démarrer sans aucune obligation !

Partir du bon pied avec Wwise