Skip to content

The UA should be able to disallow speak() from autoplaying #27

Open

Description

@csharrison

See here for context from [email protected].

I propose we only allow speak() to succeed without error if the caller frame or any of its parents have receive user activation since their last load.

There are two options for error handling in the case that speak() fails this way:

  1. Use SpeechSynthesis' existing error mechanism with either the "not-allowed" or a new type.
  2. Make speak() return a promise, to align with HTMLMediaElement.play

I slightly prefer (1) just because the ergonomics are not much different from (2), and it keeps the API surface consistent, but I'm open to either.

Activity

  1. foolip commented on Jul 10, 2018

    @foolip
    Collaborator

    Using the existing mechanism SGTM. Promises could be a later add-on that deals with all error cases.

    Is there a linkable spec concept for "caller frame or any of its parents have receive user activation since their last load" ready use here? Is there some other spec which already uses this condition? (Sounds like something that would be defined in HTML, didn't go to look.)

  2. csharrison commented on Jul 10, 2018

    @csharrison
    ContributorAuthor

    I don't think there is a linkable spec concept for this. This gets us into the guts of user activation which is not well specced at all at the moment. Fixing that is explored in whatwg/html#1903.

  3. foolip commented on Jul 10, 2018

    @foolip
    Collaborator

    https://html.spec.whatwg.org/multipage/interaction.html#triggered-by-user-activation itself does need some work, that is true, but how about the "have receive user activation since their last load" aspect of this? @mounirlamouri, assuming this should match media elements and web audio, what's the right spec incantation?

  4. mounirlamouri commented on Jul 10, 2018

    @mounirlamouri

    For both specs, we do not require a user activation. We use a concept of "allowed to play" or "allowed to start" and we let the UA define when things are allowed. Because this is an intervention, UA have different rules and we decided that what mattered was discoverability of these rules by the website.

    Regarding user activation, we have some folks working on a proper definition for it.

  5. foolip commented on Jul 10, 2018

    @foolip
    Collaborator

    OK, so that is https://html.spec.whatwg.org/multipage/media.html#allowed-to-play.

    @csharrison, referencing that concept directly won't work because it's defined as specific to media elements. Do you think an analogous definition for https://w3c.github.io/speech-api/#speechsynthesis would be best, or to generalize this concept and use it for all call sites? @mounirlamouri opinions?

  6. mounirlamouri commented on Jul 10, 2018

    @mounirlamouri

    For Web Audio, we used https://webaudio.github.io/web-audio-api/#allowed-to-start so it seems that there is precedent to re-define a concept.

  7. changed the title [-]speak() should not be allowed if there has never been user activation[/-] [+]The UA should be able to disallow speak() from autoplaying[/+] on Aug 7, 2018
  8. csharrison commented on Aug 7, 2018

    @csharrison
    ContributorAuthor

    I've altered the title of this issue to be more general, and we can discuss the precise rules for allowing speak in #35.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions