BaseAudioContext: statechange イベント

statechange イベントは、 BaseAudioContext オブジェクトに対して state メンバーが変化したときに発生します。

構文

このイベント名を addEventListener() のようなメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。

addEventListener('statechange', event => { })

onstatechange = event => { }

イベント型

一般的な Event です。

次のスニペットは AudioContext states のデモライブ実行を確認)の一部です。 onstatechange ハンドラーは現在の state を、変化するたびにコンソールへログ出力します。

audioCtx.onstatechange = function() {
  console.log(audioCtx.state);
}

仕様書

Specification
Web Audio API
# dom-baseaudiocontext-onstatechange

ブラウザーの互換性

BCD tables only load in the browser

関連情報