Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: event when user seeks in video #275

Open
BasToTheMax opened this issue Feb 14, 2025 · 0 comments
Open

Feature request: event when user seeks in video #275

BasToTheMax opened this issue Feb 14, 2025 · 0 comments

Comments

@BasToTheMax
Copy link

Hello there!

First of all, thanks for making this.
I am currently working on a simple system so sync audio with my "video".
It works so far, but there isn't really a way to know if the user seeks in the video so i can change the audio position too.

Would love to see something like this

player.addEventListener('seek', (seconds) => {
    console.log(`User seeked ${seconds} in to the video!`);
});

My current solution:

setInterval(() => {
    if (player.getCurrentTime() < audio.duration) {
        audio.currentTime = player.getCurrentTime();
        if (state == 1 && audio.paused == true) {
            audio.play();
        }
    } else {
        console.log('Audio already ended!');
        audio.pause();
    }
}, 1000);

This simply sets the current audio position to the position of the video every second.
(i set the state to 1 on play, and to 0 on pause)

Regards,
Bas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant