简体   繁体   中英

How to access your systems media player when coding a VSCode extension, through a nodejs backend

I am using the library play-sound . I have tried 2 different statements, which yield different results, neither successful. When I use

const player = require('play-sound')({player: "mplayer"}) The extension works with no error codes, but no audio is played.

const player = require('play-sound')() The extension still runs, but I get the error code

Could not play sound: Error: Couldn't find a suitable audio player . Likewise, no sound is produced.

How can I access my systems audio while coding a vscode extension?

PS: Here is the code I run to play the audio

player.play('noise.mp3', (err) => {
            if (err) console.log(`Could not play sound: ${err}`);
        });

You should try like this:

const player = require('play-sound')(opts = {});

// $ mplayer foo.mp3 
player.play('foo.mp3', function(err){
  if (err) throw err
})

I have just tried this on my system it plays, just make sure the path for the file is correct and it is mp3 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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