问题
I'm experiencing an issue when trying to capture the audio levels from the Opentok publisher. My code works perfectly on Chrome (Version 70.0.3538.110) but are not working as expected on Safari (Version 12.0.1). I'm using @opentok/client Version 2.15.4 and opentok node server Version 2.8.0.
Here is my code:
this.publisher.on('audioLevelUpdated', (event) => {
console.log("event.audioLevel: " + event.audioLevel);
// etc...
In Chrome, I get the following as expected:
In Safari, the value of 'event.audioLevel' is 0 after after a short period of time (about 5 seconds) for some reason:
Any thoughts as to why this is happening? Any help is much appreciated!
回答1:
I just tried this using Safari 12 and it was working fine. Try updating to the latest Safari 12 and see whether you are still seeing this problem. Quite a few WebRTC related bugs have been fixed in Safari 12.
Here is the jsbin I put together to test the audio level.
https://output.jsbin.com/sugeyim
const publisher = OT.initPublisher();
const audioEl = document.querySelector('#audioLevel');
publisher.on('audioLevelUpdated', ({audioLevel}) => {
audioEl.innerHTML = audioLevel;
});
来源:https://stackoverflow.com/questions/53709450/opentok-audiolevelupdated-published-event-not-working-as-expected-on-safari