简体   繁体   English

在 vscode 扩展中使用 Webaudio

[英]Using Webaudio in vscode extension

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.我编写了一个创建 webview 面板的 vscode 扩展程序,当用户单击我页面上的按钮时,我想播放音频缓冲区。 I have this identical code working in a test page in a browser so I think I'm doing the webaudio part correctly.我有这个相同的代码在浏览器的测试页面中工作,所以我认为我正在正确地执行 webaudio 部分。

I initialized with vscode.window.createWebviewPanel(...) .我用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? webview 中的声音是否静音? Is there something I have to do to tell vscode that sound is expected?我需要做些什么来告诉 vscode 声音是预期的吗?

Or is it just impossible to make a sound in a vscode extension?或者只是不可能在 vscode 扩展中发出声音?

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.我正在 javascript 中创建音频缓冲区,但我正在加载一些我用作源的小型.mp3文件。 So it requires XHR to receive the .mp3 file and decodeAudioData to decode it.所以它需要 XHR 接收.mp3文件并decodeAudioData进行解码。

From my experience, Web Audio API works fine in a VS Code webview panel, but its support for audio file types is very limited.根据我的经验,Web 音频 API 在 VS Code webview 面板中工作正常,但它对音频文件类型的支持非常有限。 It can't decode .mp3 files or even .wav files.它无法解码.mp3文件甚至.wav文件。

However, an .oga file (Vorbis-encoded OGG) works.但是, .oga文件(Vorbis 编码的 OGG)可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM