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

Insert audio #309

Open
ay192018 opened this issue Nov 15, 2023 · 2 comments
Open

Insert audio #309

ay192018 opened this issue Nov 15, 2023 · 2 comments

Comments

@ay192018
Copy link

How do I insert the audio of each stroke when I execute the animateCharacter method?

@ay192018
Copy link
Author

Or is there a callback function provided for each stroke to handle other

@chanind
Copy link
Owner

chanind commented Nov 15, 2023

There's not a callback for each stroke on animateCharacter(), although it's not a bad idea to add that feature. Currently to achieve what you're after you'd have to call each animateStroke() method individually. You can pass a callback to do whatever you want, e.g. play audio, then animate the next stroke. Maybe something like:

let strokeNum = 0;
const maxStrokes = 5;
const animateCb = () => {
    writer.animateStroke(strokeNum, { onComplete: animateCb });
    playAudio();
    strokeNum += 1;
    if (strokeNum < maxStrokes) {
        animateCb();
    }
}

animateCb();

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

2 participants