Using Webaudio in vscode extension

Viewed 27

I wrote a vscode extension that creates a webview panel and I'd like to play an audio buffer when the user clicks a button on my page. I have this identical code working in a test page in a browser so I think I'm doing the webaudio part correctly.

I initialized with vscode.window.createWebviewPanel(...).

When I click the button on the page, it looks like the code is working (there are no errors thrown and the expected code path happens) but I don't hear any sound.

Is there something muting the sound in the webview? Is there something I have to do to tell vscode that sound is expected?

Or is it just impossible to make a sound in a vscode extension?

EDIT:

One more detail that I forgot to mention. I am creating the audio buffer in javascript but I am loading a number of small .mp3 files that I'm using as source. So it requires XHR to receive the .mp3 file and decodeAudioData to decode it.

1 Answers

From my experience, Web Audio API works fine in a VS Code webview panel, but its support for audio file types is very limited. It can’t decode .mp3 files or even .wav files.

However, an .oga file (Vorbis-encoded OGG) works.

Related