Closed kennarddh closed 1 year ago
I can solve this with listening to timeupdate
event
const audic = new Audic(path)
audic.loop = false
await audic.play()
audic.addEventListener('timeupdate', () => {
if (audic.currentTime === audic.duration - 1) {
audic.destroy()
}
})
Workaround above doesn't seem to work stable - sometimes it repeats small part of sound just before audic.destroy().
A better workaround:
export async function yPlaySoundFile(filePath: string) {
const Audic = (await import("audic")).default;
const audic = new Audic(filePath);
audic.loop = false;
// Fix to the library
void (async () => {
const vlc = await (audic as any)._vlc;
const { repeat, loop } = await vlc.info();
if (loop) {
await vlc.command("pl_loop");
}
if (repeat) {
await vlc.command("pl_repeat");
}
})();
//
audic.addEventListener("ended", () => {
audic.destroy();
});
await audic.play();
}
Pull request here: https://github.com/Richienb/audic/pull/22
Has the fix been released yet?
If loop is set to true in
vlc
audio will always be looped even when