Play audio with Node.JS

前端 未结 7 2120
故里飘歌
故里飘歌 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:41

    Introducing, audic. It doesn't use any native dependencies and it's isomorphic so it can't break like in the answers higher up.

    Observe:

    const Audic = require("audic")
    
    const audio = new Audic("audio.mp3")
    
    // Play Audio
    audio.play()
    
    // Pause Audio
    audio.pause()
    

提交回复
热议问题