Coders Packet

Playing Audio Files using AuidoInputStream, AudioSystem class and Clip interface in Java

By Rasika Deshpande

This is a source code which plays an audio file in Java programming language. AudioInputStream, AudioSystem class and Clip interface are used.

About Code:

This program plays audio files which are in the .wav format. User defined functions are added so that the user can pause, resume or stop the audio file anytime they want. This code uses the AudioInputStream, AudioSystem class and Clip interface. Make the following imports:

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
 

How to Use this Code?

1. Make sure that the audio file you want to play is a wav file.

2. Enter the correct path of the audio file in the place of filepath.

Download project

Reviews Report

Submitted by Rasika Deshpande (RasikaDeshpande24)

Download packets of source code on Coders Packet