Richienb / audic

Play some audio.
MIT License
68 stars 9 forks source link

Process don't naturally ends #6

Closed insign closed 2 years ago

insign commented 3 years ago

The file is played but never ends on the CLI.

To Reproduce ready.js

const Audic = require("audic")
new Audic("ready.wav").play()

node ready.js plays but never exits the script.

To fix this I need to add:setTimeout(() => process.exit(), 2000) 2000 means the time to play my audio file.

Richienb commented 3 years ago
const Audic = require("audic")

const player = new Audic("ready.wav")
player.play()
setTimeout(() => {
    player.destroy()
}, player.duration)
insign commented 3 years ago
C:\Users\helio\MEGA\WORK\simpleads\easycontent\frontend\node_modules\audic\dist\index.js:118
        this._vlc.kill();
                  ^

TypeError: Cannot read property 'kill' of undefined
    at Audic.destroy (C:\Users\helio\MEGA\WORK\simpleads\easycontent\frontend\node_modules\audic\dist\index.js:118:19)
    at Timeout._onTimeout (C:\Users\helio\MEGA\WORK\simpleads\easycontent\frontend\ready.js:6:10)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Richienb commented 3 years ago

Ah. We've got to wait for the instance to start:

const Audic = require("audic")

const player = new Audic("ready.wav")
await player.play()
setTimeout(() => {
    player.destroy()
}, player.duration)
Wyrtz commented 3 years ago

player.duration simply gives me "undefined" when printed, and 0 when looking at the printed object. Both for .mp3 and .wav. I do await player.play()

Richienb commented 3 years ago

@Wyrtz Are you able to hear the audio play?

healertrix commented 3 years ago

I tried , but I was not able to hear the audio play