diff options
author | MaZderMind | 2015-04-04 12:22:51 +0200 |
---|---|---|
committer | MaZderMind | 2015-04-04 12:23:41 +0200 |
commit | 084098645828740a5f96a011eb3bd1d69c5a9e6e (patch) | |
tree | ef32de3ea3977010e9b8e873139cdbbaa83a3b33 | |
parent | 2a24e19809e3fabf6bf18f8c98040d7769052c4d (diff) |
Disable Meter in !Chrome browsers
Diffstat (limited to '')
-rw-r--r-- | assets/js/lustiges-script.js | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js index d4db5f6..417b234 100644 --- a/assets/js/lustiges-script.js +++ b/assets/js/lustiges-script.js @@ -433,18 +433,15 @@ $(function() { // multiviewer $(function() { + var audioMeter = !!window.chrome; $('body.multiview') .find('audio, video') - //.prop('muted', true) .each(function(idx, player) { var $player = $(player), $meter = $player.closest('.cell').find('.meter'), - $timer = $player.closest('.cell').find('.timer'), - ctx = new AudioContext(), - audioSrc = ctx.createMediaElementSource(player), - analyser = ctx.createAnalyser(); + $timer = $player.closest('.cell').find('.timer'); $player.on("timeupdate", function(e) { @@ -474,6 +471,18 @@ $(function() { $timer.text(txt); }); + if(!audioMeter) + { + $player.prop('muted', true); + $meter.hide(); + return; + } + + var + ctx = new AudioContext(), + audioSrc = ctx.createMediaElementSource(player), + analyser = ctx.createAnalyser(); + // we have to connect the MediaElementSource with the analyser audioSrc.connect(analyser); @@ -483,7 +492,6 @@ $(function() { var w = 100 / analyser.frequencyBinCount; for (var i = 0; i < analyser.frequencyBinCount; i++) { var c = Math.floor( i * 255 / analyser.frequencyBinCount ); - console.log(c); $('<div class="bar">') .css({ 'width': w+'%', @@ -499,7 +507,6 @@ $(function() { var frequencyData = new Uint8Array(analyser.frequencyBinCount); // we're ready to receive some data! - // loop function renderFrame() { // update data in frequencyData analyser.getByteFrequencyData(frequencyData); @@ -509,6 +516,7 @@ $(function() { $($bars[i]).css('height', frequencyData[i] / 255 * 40); } + // loop requestAnimationFrame(renderFrame); } renderFrame(); |