ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java
@@ -11,6 +11,9 @@
import com.sun.jna.Platform;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@@ -33,7 +36,8 @@
 **/
@Service
@Slf4j(topic = "cmd")
public class MediaServiceImpl implements IMediaService {
@Order(1)
public class MediaServiceImpl implements IMediaService, ApplicationRunner {
    @Resource
    VtduMapper vtduMapper;
    @Resource
@@ -47,12 +51,24 @@
    String processName = "mediamtx.exe";
    static{
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("开始加载流媒体列表");
        List<StreamInfo> paths = paths();
        for(StreamInfo path:paths)
        {
            mediaClient.removePath(path.getName());
        }
        List<Vtdu> vtduList = vtduMapper.selectVtduList(new Vtdu());
        for (Vtdu v : vtduList) {
            addPath(v.getName(), v.getRtspUrl(), v.getCodeType(), v.getIsCode());
        }
    }
    @PostConstruct
    public void initMediaMtx() {
        if (mediamtxEnabled) {
            log.info("初始化启动mediaMTX");
            if (Platform.isWindows()) {
                String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "mediamtx" + File.separator + "mediamtx.exe";
                String ymlPath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "mediamtx" + File.separator + "mediamtx.yml";
@@ -70,20 +86,6 @@
//            String[] command = {"cmd","/c","start",exePath,ymlPath};
//            CmdUtils.commandStart(command);
            }
        }
        try {
            Thread.sleep(2000); // 等待5秒
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        List<StreamInfo> paths = paths();
        for(StreamInfo path:paths)
        {
            mediaClient.removePath(path.getName());
        }
        List<Vtdu> vtduList = vtduMapper.selectVtduList(new Vtdu());
        for (Vtdu v : vtduList) {
            addPath(v.getName(), v.getRtspUrl(), v.getCodeType(), v.getIsCode());
        }
    }
@@ -456,4 +458,5 @@
            return false;
        }
    }
}