Question: I have some code where if I am clicking on a the "play" button mp3 button is being played.. the problem is that I need the mp3 paused after 5 seconds. I have tried pretty everything on the net but couldn't get any solves.

Here is my code:

```
<script>
            $(document).ready(function() {
                $("#play").click(function() {
                    $("#id1").play().delay("slow").pause();
                });
            });
        </script>
    </head>
    <body>
        Car 1:<input type="checkbox" id="checkbox" />
        Car 2:<input type="checkbox" id="checkbox2" />
  <br/><br/>
  <input type="button" value="hey you" id="do" /> 
  <audio id="id1" src="mp3.mp3"></audio>
  <button onClick="document.getElementById('id1').play()" id="play">Play</button>
  <button onClick="document.getElementById('id1').pause()" id="stop">Stop</button>
</body>

```

hope you could help me. Thanks.

Answer: 
OK, I think I understand. 

On clicking "Play", you want the the player to play a 5 second burst then go into pause mode.

Try this :

```
var t, player = $("#id1");

$("#play").click(function() {
    clearTimeout(t);
    player.play();
    t = setTimeout(function() {
        player.pause();
    }, 5000);
});

```

`clearTimeout(t)` caters for the user clicking the play button again within the 5 seconds. Without `clearTimeout(t)` the behaviour would be wrong - try it.
Use `window.setTimeout()` to trigger another piece of code after 5 seconds. See <http://www.w3schools.com/jsref/met_win_settimeout.asp>