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

how to properly pause or stop reading after completed reading a block of test? #58

Open
danielignatius opened this issue Aug 31, 2021 · 4 comments

Comments

@danielignatius
Copy link

danielignatius commented Aug 31, 2021

This is a great script. But the playlist.pause(); or the player.pause(); is not firing after the onPause fn is fired. I cant seem to stop or pause from reading the next block of text. Any advice is appreciated.

    var player = new talkify.TtsPlayer()
    .enableTextHighlighting()
    .subscribeTo({
        onSentenceComplete: function () { console.log("onSentenceComplete :)") },
        onBeforeItemPlaying: function () { console.log("onBeforeItemPlaying :)") },
        onItemLoaded: function () { console.log("onItemLoaded :)") },
        onPause: function () {
            player.pause();
            console.log("onPause :)"); 
        },
    })
    .forceVoice({name: "Zira"});

    var playlist = new talkify.playlist()
    .begin()
    .usingPlayer(player)
    .withRootSelector('.browse-wrap')
    .withTextInteraction()
    .subscribeTo({
        onPause: function () {
            playlist.pause();
            player.pause();
            console.log("onPause :))"); 
        },
    })
    .build();

    playlist.play();
@Hagsten
Copy link
Owner

Hagsten commented Aug 31, 2021

Hi @danielignatius , the onPause function is a callback that is invoked when the player pauses. It is typically invoked after a call to player.pause()

To pause playback, you can either call the players pause method or the playlists pause method.

@danielignatius
Copy link
Author

danielignatius commented Aug 31, 2021

Hi @Hagsten , thank you for the advice. I had a put a playlist.pause(); or the player.pause(); on the onPause function because it was pausing before reading the next block of text. In this case, can you share with me how to stop the web reader from reading text 2 after reading text 1. See screenshot. Is there an event I can use to catch and pause the playlist or player?

Thanks @Hagsten

Screen Shot 2021-09-01 at 8 45 25 am

@Hagsten
Copy link
Owner

Hagsten commented Sep 1, 2021

What is the purpose of pausing in the middle of the playlist?

I would say that you just include whichever paragraphs you need in the playlist by using withElements (https://github.com/Hagsten/Talkify#playlist-fluent-builder) to narrow down your scope. The playlist will always play all its paragraphs until it has played the last. Or keeping your own playlist and just using the player instance which you can control as you want :)

@danielignatius
Copy link
Author

@Hagsten Thanks for sharing your insight on how the playlist actually works.

I actually have two sections that I want the text to be read out for my audience. One section on the top (A) and the other section at the other side of the page (B). I don't want B to be read out immediately after A has been read out. Is there a way to gracefully stop B from reading out immediately after A has been read out? It would be great to stop reading B out without the audience clicking on the stop button.

I only want B to be read out if the audience click on the text or sentence.

Your suggestion is appreciated.

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