diff --git a/netty-client/pom.xml b/netty-client/pom.xml index ae3c9f6..11f9aad 100644 --- a/netty-client/pom.xml +++ b/netty-client/pom.xml @@ -26,6 +26,11 @@ jsch 0.1.55 + + com.github.biconou + AudioPlayer + 0.2.5 + diff --git a/netty-client/src/main/java/com/sv/intergration/MessageService.java b/netty-client/src/main/java/com/sv/intergration/MessageService.java index b502182..91146a9 100644 --- a/netty-client/src/main/java/com/sv/intergration/MessageService.java +++ b/netty-client/src/main/java/com/sv/intergration/MessageService.java @@ -66,6 +66,8 @@ public class MessageService { doorService.enterOpenDoor(); // 开门 logger.info("open enter door success!!!"); + PlayMusicService.INSTANCE.playHello(); + } /** @@ -76,6 +78,7 @@ public class MessageService { doorService.outOpenDoor(); // 开门 logger.info("open out door success!!!"); + PlayMusicService.INSTANCE.playBye(); } } diff --git a/netty-client/src/main/java/com/sv/intergration/PlayMusicService.java b/netty-client/src/main/java/com/sv/intergration/PlayMusicService.java new file mode 100644 index 0000000..b85525f --- /dev/null +++ b/netty-client/src/main/java/com/sv/intergration/PlayMusicService.java @@ -0,0 +1,41 @@ +package com.sv.intergration; + +import com.github.biconou.AudioPlayer.ArrayListPlayList; +import com.github.biconou.AudioPlayer.JavaPlayer; +import com.github.biconou.AudioPlayer.api.Player; + +import java.io.*; + +public enum PlayMusicService { + + INSTANCE; + + private static Player player = new JavaPlayer(); + private static ArrayListPlayList helloVoice = new ArrayListPlayList(); + private static ArrayListPlayList byeVoice = new ArrayListPlayList(); +// PlayList stopUsingVoice = new ArrayListPlayList(); + + static { + File hello = new File("/home/venue/client/hello.mp3"); + if (hello.exists()){ + helloVoice.addAudioFile(hello); + } + File bye = new File("/home/venue/client/bye.mp3"); + if (bye.exists()){ + byeVoice.addAudioFile(bye); + } + } + + public void playHello(){ + player.setPlayList(helloVoice); + player.play(); + player.close(); + } + + public void playBye(){ + player.setPlayList(byeVoice); + player.play(); + player.close(); + } + +} diff --git a/netty-client/src/main/resources/music/bye.mp3 b/netty-client/src/main/resources/music/bye.mp3 new file mode 100644 index 0000000..fd9871f Binary files /dev/null and b/netty-client/src/main/resources/music/bye.mp3 differ diff --git a/netty-client/src/main/resources/music/hello.mp3 b/netty-client/src/main/resources/music/hello.mp3 new file mode 100644 index 0000000..bf14e8a Binary files /dev/null and b/netty-client/src/main/resources/music/hello.mp3 differ diff --git a/netty-client/src/main/resources/music/waiting.mp3 b/netty-client/src/main/resources/music/waiting.mp3 new file mode 100644 index 0000000..7975fcf Binary files /dev/null and b/netty-client/src/main/resources/music/waiting.mp3 differ