var subscriber;
subscriber = void 0;
getApiAndToken = function() {
initializeSession();
};
initializeSession = function() {
session = OT.initSession(apiKey, sessionId);
session.on('streamCreated', function(event) {
session.subscribe(event.stream, 'layout', {
insertMode: 'append'
});
layout();
});
};
(function() {
var movingAvg;
subscriber.setStyle('audioLevelDisplayMode', 'off');
movingAvg = null;
return subscriber.on('audioLevelUpdated', function(event) {
var logLevel;
if (movingAvg === null || movingAvg <= event.audioLevel) {
movingAvg = event.audioLevel;
} else {
movingAvg = 0.7 * movingAvg + 0.3 * event.audioLevel;
}
logLevel = Math.log(movingAvg) / Math.LN10 / 1.5 + 1;
logLevel = Math.min(Math.max(logLevel, 0), 1);
document.getElementById('subscriberMeter').value = logLevel;
console.log(logLevel);
});
});
Hey I'm having the issue where my session.subscribe is not connected to a subscriber variable, which I can tell is preferred as you want to accomplish more advanced settings with opentok.
Now I've essentially added the session on stream created into a function. Now what I'd like to be able to do is make session subscribe be related to the subscriber variable, to a point where I can also get the audio levels from it in my current code.
Currently I get
Uncaught TypeError: Cannot read property 'setStyle' of undefined
which is expected as I have it set as undefined on the top.