From 95327570b0c7796cc6cd46f236b89c81c4f83896 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sun, 28 Jul 2024 13:55:47 +0900 Subject: [PATCH] =?UTF-8?q?2023/12/05=20=E6=99=82=E7=82=B9=E3=81=AE?= =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E3=81=AB=E5=9F=BA=E3=81=A5=E3=81=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../htmlmediaelement/preservespitch/index.md | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/files/ja/web/api/htmlmediaelement/preservespitch/index.md b/files/ja/web/api/htmlmediaelement/preservespitch/index.md index 015c5e6d103b28..4a953359beb5b6 100644 --- a/files/ja/web/api/htmlmediaelement/preservespitch/index.md +++ b/files/ja/web/api/htmlmediaelement/preservespitch/index.md @@ -1,8 +1,9 @@ --- -title: HTMLMediaElement.preservesPitch +title: "HTMLMediaElement: preservesPitch プロパティ" +short-title: preservesPitch slug: Web/API/HTMLMediaElement/preservesPitch l10n: - sourceCommit: a36633398f827c87eb593f9647ed00bf33fd5b34 + sourceCommit: c3be131cfd2c33822cb36b21cb4fca78980a6b4e --- {{APIRef("HTML DOM")}} @@ -27,12 +28,12 @@ l10n: src="https://mdn.github.io/webaudio-examples/audio-basics/outfoxing.mp3">
- +
- +
``` @@ -45,18 +46,11 @@ div { ```js const audio = document.querySelector("audio"); - -const rate = document.querySelector("#rate"); -rate.addEventListener("input", () => (audio.playbackRate = rate.value)); - -const pitch = document.querySelector("#pitch"); -pitch.addEventListener("change", () => { - if ("preservesPitch" in audio) { - audio.preservesPitch = pitch.checked; - } else if ("mozPreservesPitch" in audio) { - //deprecated - audio.mozPreservesPitch = pitch.checked; - } +document.getElementById("rate").addEventListener("change", (e) => { + audio.playbackRate = e.target.value; +}); +document.getElementById("pitch").addEventListener("change", (e) => { + audio.preservesPitch = e.target.checked; }); ``` @@ -73,4 +67,4 @@ pitch.addEventListener("change", () => { ## 関連情報 - {{domxref("HTMLMediaElement.playbackRate")}} -- [ウェブオーディオの playbackRate の説明](/ja/docs/Web/Guide/Audio_and_video_delivery/WebAudio_playbackRate_explained) +- [ウェブオーディオの playbackRate の説明](/ja/docs/Web/Media/Audio_and_video_delivery/WebAudio_playbackRate_explained)