HTMLMediaElement: preservesPitch プロパティ
Baseline 2023Newly available
Since December 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
HTMLMediaElement.preservesPitch
プロパティは、 HTMLMediaElement.playbackRate
の設定で行われた再生速度の変更を補償するために、ブラウザーが音声の音程を調整すべきかどうかを決定します。
値
論理値で、既定値は true
です。
例
preservesPitch プロパティの設定
この例には、 <audio>
要素、再生速度を制御する範囲コントロール、preservesPitch
を設定するチェックボックスがあります。
音声を再生し、再生速度を調整し、チェックボックスを有効・無効にしてみてください。
html
<audio
controls
src="https://mdn.github.io/webaudio-examples/audio-basics/outfoxing.mp3"></audio>
<div>
<label for="rate">再生レートを調整:</label>
<input id="rate" type="range" min="0.25" max="3" step="0.05" value="1" />
</div>
<div>
<label for="pitch">ピッチを維持:</label>
<input type="checkbox" id="pitch" name="pitch" checked />
</div>
js
const audio = document.querySelector("audio");
document.getElementById("rate").addEventListener("change", (e) => {
audio.playbackRate = e.target.value;
});
document.getElementById("pitch").addEventListener("change", (e) => {
audio.preservesPitch = e.target.checked;
});
仕様書
Specification |
---|
HTML # dom-media-preservespitch-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
preservesPitch |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Requires a vendor prefix or different name for use.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.