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

accessing this.elem.contentWindow throws null reference exception after video is removed from DOM #93

Open
raulgspan opened this issue Jul 30, 2022 · 2 comments · May be fixed by #94
Open

Comments

@raulgspan
Copy link

player-0.1.0.min.js:formatted:224 Uncaught TypeError: Cannot read properties of null (reading 'postMessage')
at d.Player.send (player-0.1.0.min.js:formatted:224:55)
at d.Player.ready (player-0.1.0.min.js:formatted:255:18)
at d.Player.receive (player-0.1.0.min.js:formatted:240:120)
at player-0.1.0.min.js:formatted:208:15

@raulgspan raulgspan linked a pull request Jul 30, 2022 that will close this issue
@richard-stafflink
Copy link

Getting this error quite a bit.
Any work-arounds?

@richard-stafflink
Copy link

richard-stafflink commented May 10, 2024

Found a work-around:

  useEffect(() => {

    const player = Player(ref.current.querySelector('iframe'))

    player.on('ready', () => {...}
    player.on('play', () => {...}
    player.on('seek', () => {...}
    ......
    
    return () => {
      // HACK: This function gets called in the player.js lib after the player is destroyed
      // So that we don't get errors, we override to a noop function
      player.send = function () {}
      player?.off('ready')
      player?.off('play')
      player?.off('pause')
      player?.off('ended')
      player?.off('seek')
    }

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

Successfully merging a pull request may close this issue.

2 participants