فهرست منبع

重复10次10

TitanWong 1 سال پیش
والد
کامیت
5351976756
1فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 4 1
      src/main/java/com/zhili/stationcontrol/tts/service/impl/MusicServiceImpl.java

+ 4 - 1
src/main/java/com/zhili/stationcontrol/tts/service/impl/MusicServiceImpl.java

@@ -34,6 +34,7 @@ public class MusicServiceImpl implements MusicService {
     @Override
     public Integer start(String path, Integer vol) {
         synchronized (this) {
+            log.info("start music cmd:{}",cmd);
             cmd = "play -v " + Float.valueOf(new Integer(vol).toString()) / 100 + " " + path;
             startCmd = true;
             repeat = true;
@@ -43,7 +44,9 @@ public class MusicServiceImpl implements MusicService {
 
     @Override
     public void stop() {
+
         synchronized (this) {
+            log.info("stop music");
             endCmd = true;
             repeat = false;
         }
@@ -77,7 +80,7 @@ public class MusicServiceImpl implements MusicService {
     @Scheduled(fixedRate = 500)
     public void repeat() {
         synchronized (this) {
-            if (p == null) {
+            if (p == null && cmd != null) {
                 try {
                     p = Runtime.getRuntime().exec(cmd);
                 } catch (IOException e) {