Play audio with Node.JS

前端 未结 7 2102
故里飘歌
故里飘歌 2021-02-01 15:52

I\'m currently using child_process and command-line mplayer to play audio on the local machine, with my Node.JS application. This works, but it\'s not really an exc

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 16:48

    You can use play-sound module also:

    Install using npm, Run command:

    npm install play-sound --save
    

    Now use in your code:

    var player = require('play-sound')(opts = {})
    
     player.play('./music/somebody20.flac', function (err) {
       if (err) throw err;
       console.log("Audio finished");
     });
    

提交回复
热议问题