Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have saved audio files in a folder, I want to retrieve and display them on a jsp page and make them clickable, as they are clicked I want them to played.

File dir = new File("D:\\nameoffolder\\"+ foldername);
dir.mkdir();

String path = dir.toString();


String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();

for(int i = 0;i < listOfFiles.length;i++)
{

if (listOfFiles[i].isFile())
{
files = listOfFiles[i].getName();
if (files.endsWith(".mp3") || files.endsWith(".mp3"))
{
out.println(files);

}
}
}


here I can retrieve them but it is a strig format which is not clickable.
output is audioname.mp3 in a readonly string format.
Posted
Comments
Richard MacCutchan 13-Sep-15 3:19am    
You need to create the correct HTML types for the links so the browser knows what to do when the user clicks them.
Member 9671810 13-Sep-15 4:53am    
I made a hyperlink, using this code
out.println("");
out.println(files);
out.println("
");

and audio player

out.println("<audio controls="">");


out.println("");
out.println("Your browser does not support the audio element.");
out.println("");


but audio is not getting played, cause invalid source. :/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900