java mp3 player while code is running

Solutions on MaxInterview for java mp3 player while code is running by the best coders in the world

showing results for - "java mp3 player while code is running"
Camilla
01 Apr 2019
1THIS IS JUST ONE OF MANY OPTIONS
2For this to work, you have to download and add
3the .jar file linked in the source.
4
5import javazoom.jl.player.*;
6import java.io.FileInputStream;
7
8public class PlaySomeMusic{
9		
10	public static void main(String[] args) {
11
12        try{
13
14             FileInputStream fis = new FileInputStream("Music.mp3");
15             Player playMP3 = new Player(fis);
16
17             playMP3.play();
18
19        }  catch(Exception e){
20             System.out.println(e);
21           }
22    }
23}
24
25
26If your new to programming, you might be wondering how you can play the song
27while your code is running, because right now, whenever you issue the 
28playMP3.play();
29command, the programm waits for the mp3 file to be finished and then
30continues running your code. 
31To solve this, just read up on Java Threads on the internet, 
32because it allows you to run multiple things at the same time.