Question

I have set up a basic test page for OpenTok using API Key, Session and Token (for publisher). Is based on the QuickStart with code added to track the microphoneLevelChanged event. Page code is available here. The important lines are:

var apiKey = "API KEY HERE";
var sessionId = "SESSION ID HERE";
var token = "TOKEN HERE";

function sessionConnectedHandler(event) {
    session.publish(publisher);
    subscribeToStreams(event.streams);
} 
function subscribeToStreams(streams) {
    for (var i = 0; i < streams.length; i++) {
        var stream = streams[i];
        if (stream.connection.connectionId != session.connection.connectionId) {
            session.subscribe(stream);
        }
    }
}
function streamCreatedHandler(event) {
    subscribeToStreams(event.streams);
    TB.log("test log stream created: " + event);
}

var pubProps = { reportMicLevels: true };
var publisher = TB.initPublisher(apiKey, null, pubProps);
var session = TB.initSession(sessionId);
session.publish(publisher);

session.addEventListener("sessionConnected", sessionConnectedHandler);
session.addEventListener("streamCreated", streamCreatedHandler);
session.addEventListener("microphoneLevelChanged", microphoneLevelChangedHandler);
session.connect(apiKey, token);

function microphoneLevelChangedHandler(event) {
    TB.log("The microphone level for stream " + event.streamId + " is: " + event.volume);
}

I know that the logging works, as the logs show up from streamCreatedHandler. However, I am not getting any events logged in the microphoneLevelChangedHandler function. I have tried this with both one and two clients loading the pages (videos show up just fine).

What do I need to do to get the microphoneLevelChanged events to show up?

Was it helpful?

Solution

OpenTok's WebRTC js library does not have a microphoneLevelChanged event so there is nothing you can do, sorry.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top