1

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.

Paulie
  • 1,940
  • 3
  • 20
  • 34

1 Answers1

1

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.

Thai
  • 10,746
  • 2
  • 45
  • 57
  • Thanks. This is an audio buffer that I'm creating from scratch but I am assembling them from `.mp3` input. Maybe that's the problem. – Paulie Sep 06 '22 at 14:08
  • 1
    [Support for MP3 may be coming soon as VS Code is currently exploring the implementation of a video/audio player.](https://github.com/microsoft/vscode/issues/161823) – Thai Sep 28 '22 at 03:28
  • Cool! I was hoping to get to this last week but didn't. Maybe it will just fix itself. Thanks for the info. – Paulie Sep 30 '22 at 13:48