ほげほげ

プログラミング、英会話、ヨガ、料理などの備忘録など。

Audio APIで複数音声を同時再生

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<a id="play">play</a>
<script>
$(function(){
    var s1 = new Audio('hello.m4a') ;
    var s2 = new Audio('hello.m4a') ;
    $('#play').click(function(){
        s1.play() ;
        setTimeout(function(){
            s2.play() ;
        },100);
    }) ;
});
</script>
</body>
</html>