Search code examples
javaaudiojavasoundcd

Access to CD-ROM using Java


I would like to ask if there is any possibility to access the cdrom device via sound libraries in Java.

What I want to do is to mute CD Analog. I've searched using google for a long time, but there is no information about such an operation. I assume that this is trivial or very complex.

This simple code list my mixers:

try
{
    Mixer.Info [] mixerList = AudioSystem.getMixerInfo();
    for (Mixer.Info mixerInfo : mixerList)
    {
        System.out.println();
        System.out.println("MIXER: "+ mixerInfo.getName());
        Mixer mixer = AudioSystem.getMixer(mixerInfo);
        Line.Info[] li = mixer.getSourceLineInfo();
        System.out.println("LINES:");
        for (Line.Info info2 : li)
        {
            System.out.println(info2.toString());
        }

    }
} 
catch (Exception e)
{
    e.printStackTrace();
}

The output is:

MIXER: Primary Sound Driver
LINES:
interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
interface Clip supporting 8 audio formats, and buffers of at least 32 bytes

MIXER: Speakers (Realtek High Definition Audio)
LINES:
interface SourceDataLine supporting 8 audio formats, and buffers of at least 32 bytes
interface Clip supporting 8 audio formats, and buffers of at least 32 bytes

MIXER: Primary Sound Capture Driver
LINES:

MIXER: Desktop Microphone (Cinema - Mi
LINES:

MIXER: Microphone (Realtek High Defini
LINES:

MIXER: Port Speakers (Realtek High Definiti
LINES:

MIXER: Port Desktop Microphone (Cinema - Mi
LINES:
MICROPHONE source port

MIXER: Port Microphone (Realtek High Defini
LINES:
MICROPHONE source port

But there is no such device like cd analog. When I try obtaining a particular port from the mixer using Port.Info.COMPACT_DISC there is an exception no such device.

Can anybody assist me with this issue?


Solution

  • Have a look at java-avm library:

    java-avm (Audio Video Media) is a Java API for accessing and controlling disc drives, particularly CD-ROM and CD-R(W) drives, removable drives, and loopback devices.

    ...

    CD-ROM Specific:

    • Control CD-Audio playback with volume adjustment.