In the following piece of code, execution of eval() is not working in FireFox.
Pls provide the suggestions.

Code:
var str="audioElement[0].play();";

for(i=0;i<fileNames.length-1;i++)
{
			
str = str + "audioElement[" + i + "].addEventListener('ended', function() {audioElement[" + (i+1) + "].play();}, false);";
}

str = str + "audioElement[" + (fileNames.length-1) + "].addEventListener('ended', function(){}, false);";
eval(str);
Here, filenames array is having the array of HTML5 audio tag elements.