package com.izouma.dingdong;

import com.izouma.dingdong.exception.BusinessException;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

@RunWith(SpringRunner.class)
@SpringBootTest
public class VoiceTest {
    @Test
    public void test() throws IOException, JavaLayerException {
        int voiceId = 2;
        File file;

        switch (voiceId) {
            case 1:
                file = new File("/Users/qiufangchao/Desktop/1.mp3");
                break;
            case 2:
                file = new File("/Users/qiufangchao/Desktop/2.mp3");
                break;
            default:
                throw new BusinessException("语音错误");
        }


        FileInputStream f = new FileInputStream(file);
        Player player = new Player(f);
        player.play();
    }
}
