単なる問題です。TypeError: 'HTMLMediaElement'で 'play'を実行できませんでした:不正な呼び出し
HTMLMediaElement
メソッドを変数に割り当てたいとします。
// 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
誰でもこのエラーが発生した理由を知っていますか?
私はあなたが必要だと思います'this'を' video'にバインドするのですか? --- Yep、binding works、 'play = play.bind(video)' – evolutionxbox
この質問は重複しているように感じますが、私はデュープのターゲットを見つけることができません。前の質問が見つからない場合は – evolutionxbox
。回答ブロックへの回答を投稿することができます。 – WendellLiu