discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
327 stars 110 forks source link

Changing the playbackDuration of a resource, doesn't seek it #168

Closed stijnb1234 closed 3 years ago

stijnb1234 commented 3 years ago

Please describe the problem you are having in as much detail as possible: When I use resource.playbackDuration = seek;, it doesn't seek the resource when I play it. It will just start playing at the beginning.

Include a reproducible code sample here, if possible:

const connection = joinVoiceChannel({
    channelId: channel.id,
    guildId: channel.guild.id,
    adapterCreator: channel.guild.voiceAdapterCreator,
});

const player = createAudioPlayer();

const seek = 5000; //Seek 5 sec

const resource = createAudioResource("./music.mp3", { inlineVolume: true });
resource.volume.setVolume(0.4);
resource.playbackDuration = seek;

player.play(resource);

connection.subscribe(player);

Further details:

Relevant client options:

amishshah commented 3 years ago

playbackDuration is intended as a read-only property, changing it won't do anything.

This library does not yet support seeking, if you'd like to do it, you'd need to use FFmpeg or some other tool.

stijnb1234 commented 3 years ago

Ah, okay. Because it's not defined as readOnly in the code itself. :P

https://github.com/discordjs/voice/issues/30#issuecomment-774542836

Here you indicate that examples will come for it. Where can I find them? I'm not so familiar with ffmpeg that I can put that together myself. :P

stijnb1234 commented 3 years ago

161 did it for me. ;)