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

PlayerStateChanged event missing in type declaration. (npm amazon-ivs-player) #80

Open
badrddinb opened this issue Jun 26, 2023 · 2 comments

Comments

@badrddinb
Copy link

The IVS Player TS SDK includes the PlayerStateChanged event in its runtime, but it has not been included in the TypeScript type declarations.

@johnBartos
Copy link
Contributor

Hey @badrddinb, I'm pretty sure that's intended, the PlayerStateChanged event is private. We make some events private by design. While we can't stop you from using them, we offer no support or guarantees that we won't break that API in future versions. The only public events are those included in the type definition file and the docs.

That being said, what's your use case for having this event?

@blfunex
Copy link

blfunex commented Aug 31, 2023

I work with @badrddinb, we use the event in react to detect when the player is buffering to signal it to the user in UI.

  useEffect(() => {
    if (!player) return

    const stateChangedListener = (state: unknown) => {
      setIsPlayerBuffering(state === PlayerState.BUFFERING)
    }

    // The IVS Player TS SDK includes the PlayerStateChanged event in its runtime,
    // but it has not been included in the TypeScript type declarations.
    // Reported: https://github.com/aws-samples/amazon-ivs-player-web-sample/issues/80
    const PlayerStateChanged = 'PlayerStateChanged' as PlayerEventType
    player.addEventListener(PlayerStateChanged, stateChangedListener)

    return () => {
      player.removeEventListener(PlayerStateChanged, stateChangedListener)
    }
  }, [player])

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

3 participants