Created
February 22, 2011 18:10
-
-
Save scottfrazer/839080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.io.File; | |
import javax.swing.JOptionPane; | |
import javazoom.jl.player.Player; | |
import java.io.BufferedInputStream; | |
import java.io.FileInputStream; | |
public class mp3 | |
{ | |
public static void main(String[] args) | |
{ | |
// User Interface | |
String bandString = JOptionPane.showInputDialog("Please enter a band you would like to listen to: "); | |
// Finding music by File name. | |
File musicdir = new File("C:\\java\\Music Test"); | |
String[] files = musicdir.list(); | |
if (files != null) | |
{ | |
for (int i=0; i < files.length; i++) | |
{ | |
if (files[i].contains(bandString)) | |
{ | |
try { | |
FileInputStream fis = new FileInputStream(files[i]); | |
BufferedInputStream bis = new BufferedInputStream(fis); | |
Player player = new Player(bis); | |
player.play(); | |
} catch (Exception e) { | |
System.out.println(e); | |
} | |
break; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment