Skip to content

Commit

Permalink
ちょいアプデ
Browse files Browse the repository at this point in the history
  • Loading branch information
AXT-AyaKoto committed Jul 29, 2024
1 parent 8c7dcea commit eba32fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions htmlmediaelement-play-event/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@
<body>
<p>VOICEVOX:ナースロボ_タイプT</p>
<audio src="./test.wav"></audio>
<button onclick="play()">再生</button>
<pre></pre>
<button onclick="play()">Play Test Audio</button>
<pre>The logs will be output here.
The "currentTime" of "play" and "playing" should be very close to 1.0000.
</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`;
document.querySelector("pre").innerText += `play :\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`;
document.querySelector("pre").innerText += `playing :\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`;
document.querySelector("pre").innerText += `timeupdate :\n currentTime : ${audio.currentTime.toFixed(4)}\n fired at : ${time.toFixed(4)}\n diff : ${(audio.currentTime - time).toFixed(4)}\n`;
}, 1000);
}, {
once: true
Expand Down

0 comments on commit eba32fc

Please sign in to comment.