package com.ruoyi.media.service.impl;
|
|
import com.sun.jna.Platform;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PostConstruct;
|
import java.io.File;
|
import java.io.IOException;
|
|
/**
|
* @Description:
|
* @ClassName: webrtcService
|
* @Author: 刘苏义
|
* @Date: 2023年07月26日13:43:07
|
* @Version: 1.0
|
**/
|
@Component
|
public class webrtcService {
|
@PostConstruct
|
public void init() {
|
if (Platform.isWindows()) {
|
String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "webrtc" + File.separator + "setup.bat";
|
|
try {
|
// 构建启动命令,使用cmd /c start命令来启动可执行程序并显示命令提示符窗口
|
String[] cmd = {"cmd", "/c", "start", exePath};
|
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
|
processBuilder.redirectErrorStream(true); // 将错误输出重定向到标准输出
|
Process process = processBuilder.start();
|
// 如果你想等待程序完成
|
int exitCode = process.waitFor();
|
} catch (IOException | InterruptedException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
}
|