Web Audio API playbackRate

User Help for Mozilla Firefox
Post Reply
Heretic86
Posts: 2
Joined: April 20th, 2021, 1:07 pm

Web Audio API playbackRate

Post by Heretic86 »

This might be a bug in Firefox as I can get it to work in Chrome, but not Firefox, on either a Windows or Kubuntu VM. Not sure, but I would put money on me doing something incorrect over being a possible bug. Anyway...

This should be something that is REALLY simple, but just isnt.

Setting the playbackRate without the Web Audio API works fine, at least in Firefox (where I am having trouble)...

Code: Select all

var audio = new Audio();
audio.src = 'some_stream.php?id=x'; // ID serves different files
audio.playbackRate = 0.5;  // Controlled by a Range Input elsewhere on page
audio.play();
Now when I try to implement the Web Audio API, for an Analyzer (canvas), then playbackRate no longer changes my playbackRate!

Code: Select all

aCtx = new (window.AudioContext || window.webkitAudioContext)();
audio_source = aCtx.createMediaElementSource(audio);

function setupGraph(){
  graph.width = 222;
  graph.height = 20;
  ctx = graph.getContext('2d');
  analyzer = aCtx.createAnalyser();
  analyzer.fftSize = 256;      
  audio_source.connect(analyzer);
  analyzer.connect(aCtx.destination);
  graphAnimator();
}
The audio plays, volume works fine, and the Analyzer Graph displays bands in the Canvas (ctx) just fine.

This works in Chrome but not in Firefox? What am I doing wrong?
Post Reply