I have a program that asks for user input and opens the corresponding mp3 file from a folder.
import java.awt.*;
import java.io.*;
import java.util.*;
class openmp3{
public static void main(String[] args)throws Exception{
Scanner console = new Scanner(System.in);
Desktop d = Desktop.getDesktop();
System.out.print("Enter song name: ");
String song = console.nextLine();
File f = new File("C:\\Users\\Leo\\Music\\" + song + ".mp3");
d.open(f);
}
}
This code works fine, but is there a way to ask for user input and close the music file that's playing? Maybe have the user enter 2 and close the playing file.