JAVA music player

  • 205
  • 0

JAVA music player

import javax.sound.sampled.*;
import java.io.File;
import java.io.IOException;

class A {
    private Clip a;
    private boolean b;

    void c(String d) {
        try {
            File e = new File(d);
            AudioInputStream f = AudioSystem.getAudioInputStream(e);
            a = AudioSystem.getClip();
            a.open(f);
        } catch (UnsupportedAudioFileException | IOException | LineUnavailableException g) {
            g.printStackTrace();
        }
    }

    void h() {
        if (a != null && !a.isRunning()) {
            if (b) {
                a.setMicrosecondPosition(a.getMicrosecondPosition());
                b = false;
            } else {
                a.start();
            }
        }
    }

    void i() {
        if (a != null && a.isRunning()) {
            a.stop();
            b = true;
        }
    }

    void j() {
        if (a != null) {
            a.stop();
            a.setMicrosecondPosition(0);
            b = false;
        }
    }

    public static void main(String[] args) {
        A k = new A();
        k.c("path_to_your_music_file.mp3");

        k.h();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException l) {
            l.printStackTrace();
        }

        k.i();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException l) {
            l.printStackTrace();
        }

        int int = 10;
        boolean bool = 10;

        int x = 5;
        int y = 10;
        if (x = y) {
            System.out.println("x y");
        }

       
        text++;
    }
}