Reputation: 296
I have a file with a story Demo story. When I move to the next page, I am using the right arrow key. The old page continues playing while I am in the new page and I need to hear the new record.
I am still in the same file when I go to the next page.
<footer>
<div style="position:relative;width:100%;margin-top:0px;margin-bottom:0px;">
<div style="width:960px;height:94px;position:relative;margin:0px;margin-left:auto;margin-right:auto;margin-top:5px;margin-bottom:5px;padding:0px;overflow:hidden">
<audio controls="controls">
<source src="CarlyAndHerLemons1.ogg" type="audio/ogg" />
<source src="CarlyAndHerLemons1.mp3" type="audio/mpeg" />
</audio>
</footer>
I think I should use by code similar to document.getElementById('demo').pause()
Many thanks.
Upvotes: 0
Views: 1219
Reputation: 20424
Give your audio tag an ID and then use:
document.getElementById('yourAudioTagID').pause();
Also this page might be useful.
Edit:
Here is a JSFiddle
Demo.
Upvotes: 1