In order to play Mp3 files in Java , you need to download jl1.0.jar from the website
javazoom.net. After downloading put the jar into Eclipse or Netbeans buildpath and execute below code.
Program to demonstrate how to play Mp3 files in Java
Program to demonstrate how to play Mp3 files in Java
package com.hubberspot.example; import java.io.BufferedInputStream; import java.io.FileInputStream; import javazoom.jl.player.Player; public class Mp3Player { private String filename; private Player player; public Mp3Player(String filename) { this.filename = filename; } public void play() { try { BufferedInputStream buffer = new BufferedInputStream( new FileInputStream(filename)); player = new Player(buffer); player.play(); } catch (Exception e) { System.out.println(e); } } public static void main(String[] args) { Mp3Player mp3 = new Mp3Player("song.mp3"); mp3.play(); } }