客户端支持播放音频
This commit is contained in:
@@ -26,6 +26,11 @@
|
|||||||
<artifactId>jsch</artifactId>
|
<artifactId>jsch</artifactId>
|
||||||
<version>0.1.55</version>
|
<version>0.1.55</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.biconou</groupId>
|
||||||
|
<artifactId>AudioPlayer</artifactId>
|
||||||
|
<version>0.2.5</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public class MessageService {
|
|||||||
doorService.enterOpenDoor();
|
doorService.enterOpenDoor();
|
||||||
// 开门
|
// 开门
|
||||||
logger.info("open enter door success!!!");
|
logger.info("open enter door success!!!");
|
||||||
|
PlayMusicService.INSTANCE.playHello();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,6 +78,7 @@ public class MessageService {
|
|||||||
doorService.outOpenDoor();
|
doorService.outOpenDoor();
|
||||||
// 开门
|
// 开门
|
||||||
logger.info("open out door success!!!");
|
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