java mp3 播放器

2020-01-14 12:06:07 浏览数 (1)

代码语言:javascript复制
package com.stevezong.mp3palyer;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;

public class Palyer {
    public static void main(String[] args) {
        try {
            File file = new File("d:/music");
            File[] files = file.listFiles();
            for(File sub:files){
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(sub));
                Player player  =new Player(bis);
                player.play();
                player.close();

            }
        } catch (JavaLayerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

0 人点赞