버전

menu_open

JavaScript, In browser - WAMP

Initializing the project

Note.gif
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="bower_components/autobahnjs/autobahn.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??.?.?

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요