open sound Line - Java javax.sound.sampled

Java examples for javax.sound.sampled:Sound

Description

open sound Line

Demo Code

// All rights reserved.
//package com.java2s;

import javax.sound.sampled.*;

public class Main {
    public static SourceDataLine openLine(final AudioFormat audioFormat)
            throws LineUnavailableException {
        DataLine.Info dataLineInfo = new DataLine.Info(
                SourceDataLine.class, audioFormat);
        Line line = AudioSystem.getLine(dataLineInfo);
        SourceDataLine sourceDataLine = (SourceDataLine) line;
        sourceDataLine.open(audioFormat);
        sourceDataLine.start();//from  w  w w.ja v a 2  s.  co m
        return sourceDataLine;
    }
}

Related Tutorials