TypeError: Failed to execute 'play' on 'HTMLMediaElement': Illegal invocation

Viewed 2881

Just a simple problem.

I want to assign a HTMLMediaElement method to variable.

// html part
<video id="player" ... />

// js part
const video = document.querySelector('#player')
const play = video.play

video.play() // works!

play() // error!

Uncaught (in promise) TypeError: Failed to execute 'play' on 'HTMLMediaElement': Illegal invocation

anyone knows why this error happened?

1 Answers
Related