Recently, I was trying some media API and found the JDK 1.6 doesn’t play MP3 files out of the box. So, I searched a little and found JLayer that can play mp3 format, you only have to include its jar file. Other than JLayer there’s Java Media Framework available which involves many installation and configuration steps before getting the code to work. With JLayer you just need to include its dependency like:

<dependency>
            <groupId>de.huxhorn.sulky</groupId>
            <artifactId>de.huxhorn.sulky.3rdparty.jlayer</artifactId>
            <version>1.0</version>
        </dependency>

and use the API like:

File file = new File("Test.mp3");
log.info("located media at "+file.getAbsolutePath());
AdvancedPlayer player = new AdvancedPlayer(new FileInputStream(file), FactoryRegistry.systemRegistry().createAudioDevice());
log.info("Starting the music... ");
player.play();