Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play sound in the WebView provided by vscode

I want to develop a plug-in to play local sound.So I make a demo for test with audio :

<audio src="vscode-resource:/Users/asure/Documents/Projects/test/EffectMove.mp3" controls>

/Users/asure/Documents/Projects/test it's the directory where I tested it.I also tested after adding it to localResourceRoots.Below was what I get.

player
It seems that sound didn't load correctly while no errors can be found in console window.I was confused whether vscode disable audio related content in webview or something was wrong in my code.
Does anyone know how to play sound in the webview provided by vsocde

like image 367
Asurance Avatar asked Dec 17 '25 09:12

Asurance


1 Answers

VSCode does not support playing sound with audio tag in WebView. you can use web audio API instead.

and there is already an extension that plays local sound files with web audio API.

like image 84
invalid Avatar answered Dec 20 '25 02:12

invalid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!