I did the following to solve the problem of multiple audio notes playing. Now using the following code only one audio is played at one time. Also, if you pause one audio and play another one and then play the paused audio then it will play from the point it was paused.
Below this is the HTML code
<div class='audiowithduration' id='"+ notes.note_id +"'>
<div id='"+ notes.note_id +"' class='detailrecording'>
<img src='../images/playrecord.png' class='detailplay' onclick='playAudio(this);'/>
<img src='../images/pauserecord.png' class='detailpause' onclick='pauseAudio(this);' hidden/>
<input class='seekbar' type='range' step='any' min='0' value='0' disabled />
</div>
<span class='timeduration'>" + timeDuration + "</span>
<audio class='audioNote' id='"+ notes.note_id +"' src='"+ audioNotePath +"' type=audio/mpeg preload='metadata'>
</audio>
</div>
Below is the javascript code
/*Function to play an audio note*/
function playAudio(parentElement)
{
var audioNoteId = parentElement.parentNode.id;
//Get the audio id and tag value to play
var song = $('#'+audioNoteId).find('.audioNote')[0];
//Pause any audio that is already playing
if (curPlaying)
{
$("audio", "#" + curPlaying)[0].pause();
}
if (song.paused)
{
song.play();
curPlaying = $('#'+audioNoteId).find('.audioNote')[0].id;
}
else
{
song.pause();
}
}
/*Function to pause an audio note*/
function pauseAudio(parentElement)
{
var audioNoteId = parentElement.parentNode.id;
//Get the audio id and tag value to pause
var song = $('#'+audioNoteId).find('.audioNote')[0];
song.pause();
}