1
我已經使用API Key,Session和Token(針對發佈者)爲OpenTok設置了一個基本測試頁面。基於QuickStart,添加了代碼以跟蹤microphoneLevelChanged事件。頁面代碼是available here。最重要的線路有:使用OpenTok無法查看MicrophoneLevel和VolumeEvent會話信息
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);
}
我知道,記錄工作,爲原木streamCreatedHandler
顯示出來。但是,我沒有收到記錄在microphoneLevelChangedHandler
函數中的任何事件。我已經試過這一點與一個和兩個客戶端加載頁面(視頻顯示很好)。
我需要做什麼才能讓microphoneLevelChanged
事件顯示出來?
這真的是一個恥辱......谷歌聚會的風格自動對焦是非常錯過。 – opsb