Kaynağa Gözat

重复10次17

TitanWong 1 yıl önce
ebeveyn
işleme
b587bc212b

+ 9 - 0
src/main/java/com/zhili/stationcontrol/tts/service/impl/MusicServiceImpl.java

@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.PostConstruct;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -25,6 +26,14 @@ public class MusicServiceImpl implements MusicService, Runnable {
     //1:重复播放,0:不重复
     Boolean repeat = false;
 
+    Thread thread;
+
+    @PostConstruct
+    public void init(){
+        this.thread = new Thread(this);
+        this.thread.start();
+    }
+
     @Override
     public Integer start(String path, Integer vol) {
         synchronized (this) {