客户端支持播放音频

This commit is contained in:
2023-12-14 17:33:51 +08:00
parent 47327e8bf1
commit 8ada48034d
6 changed files with 49 additions and 0 deletions

View File

@@ -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>

View File

@@ -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();
} }
} }

View File

@@ -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();
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.