-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTMLMediaElementのplayイベントの挙動を確認するためのサンプルを追加
- Loading branch information
1 parent
98016e0
commit 8c7dcea
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>test</title> | ||
</head> | ||
|
||
<body> | ||
<p>VOICEVOX:ナースロボ_タイプT</p> | ||
<audio src="./test.wav"></audio> | ||
<button onclick="play()">再生</button> | ||
<pre></pre> | ||
<script> | ||
const play = () => { | ||
const audio = document.querySelector('audio'); | ||
audio.addEventListener('play', () => { | ||
setTimeout(() => { | ||
document.querySelector("pre").innerText += `playイベント発火から1秒経過 :\n currentTime : ${audio.currentTime.toFixed(4)}\n`; | ||
}, 1000); | ||
}); | ||
audio.addEventListener('playing', () => { | ||
setTimeout(() => { | ||
document.querySelector("pre").innerText += `playingイベント発火から1秒経過 :\n currentTime : ${audio.currentTime.toFixed(4)}\n`; | ||
}, 1000); | ||
}); | ||
audio.addEventListener('timeupdate', () => { | ||
const time = audio.currentTime; | ||
setTimeout(() => { | ||
document.querySelector("pre").innerText += `timeupdateイベント発火から1秒経過 :\n currentTime : ${audio.currentTime.toFixed(4)}\n fired at : ${time.toFixed(4)}\n diff : ${(audio.currentTime - time).toFixed(4)}\n`; | ||
}, 1000); | ||
}, { | ||
once: true | ||
}); | ||
audio.play(); | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
Binary file not shown.