Page 801 - 2
P. 801

}
            }


            Music클래스
            private Player player;
            private boolean isLoop;
            private File file;
            private FileInputStream fis;
            private BufferedInputStream bis;


            public Music(String name, boolean isLoop) { //  곡의 제목과 무한반복인지 여부
                    try {
                            this.isLoop = isLoop; // isLoop  변수 초기화
                            file = new File( 음악파일.toURI());//  파일URI  가져오기
                            fis = new FileInputStream(file);
                            bis = new BufferedInputStream(fis); //  해당파일을 버퍼에 담아서 읽어옴
                            player = new Player(bis); //  해당 파일을 담을수 읽게함
                    } catch (Exception e) {
                            System.out.println(e.getMessage());
                    }
            }
            public int getTime() {
                    if (player == null)
                            return 0;
                    return player.getPosition();
            }
            public void close() {
                    isLoop = false;
                    player.close();
                    this.interrupt();
            }
            public void run() {
                    try {
                            do {
                                    player.play();
                                    fis = new FileInputStream(file);
                                    bis = new BufferedInputStream(fis);
                                    player = new Player(bis);
                            } while (isLoop);
                    } catch (Exception e) {
                            System.out.println(e.getMessage());
                    }
            }






                                                         - 801 -
   796   797   798   799   800   801   802   803   804   805   806