From 5f4915a1c401eb214ad35ac1062d020f4a296fb4 Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Thu, 30 Jan 2020 13:05:33 +0100 Subject: [PATCH] Fix volume-related functions in janus.js --- html/janus.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/html/janus.js b/html/janus.js index 67d5e6f101..5d07c49d3e 100644 --- a/html/janus.js +++ b/html/janus.js @@ -2897,8 +2897,10 @@ function Janus(gatewayCallbacks) { var config = pluginHandle.webrtcStuff; if(!config.volume[stream]) config.volume[stream] = { value: 0 }; - // Start getting the volume, if getStats is supported - if(config.pc.getStats && Janus.webRTCAdapter.browserDetails.browser === "chrome") { + // Start getting the volume, if audioLevel in getStats is supported (apparently + // they're only available in Chrome/Safari right now: https://webrtc-stats.callstats.io/) + if(config.pc.getStats && (Janus.webRTCAdapter.browserDetails.browser === "chrome" || + Janus.webRTCAdapter.browserDetails.browser === "safari")) { if(remote && !config.remoteStream) { Janus.warn("Remote stream unavailable"); return 0; @@ -2911,16 +2913,13 @@ function Janus(gatewayCallbacks) { config.volume[stream].timer = setInterval(function() { config.pc.getStats() .then(function(stats) { - var results = stats.result(); - for(var i=0; i