客户端支持播放音频
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
BIN
netty-client/src/main/resources/music/bye.mp3
Normal file
BIN
netty-client/src/main/resources/music/bye.mp3
Normal file
Binary file not shown.
BIN
netty-client/src/main/resources/music/hello.mp3
Normal file
BIN
netty-client/src/main/resources/music/hello.mp3
Normal file
Binary file not shown.
BIN
netty-client/src/main/resources/music/waiting.mp3
Normal file
BIN
netty-client/src/main/resources/music/waiting.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user