修正打包jar后snap路径问题,兼容windows路径
parent
fa4b73cb52
commit
b11c57d4b5
|
@ -24,7 +24,6 @@ import gov.nist.javax.sip.stack.SIPDialog;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -32,13 +31,11 @@ import org.springframework.util.ResourceUtils;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
import javax.sip.ClientTransaction;
|
import javax.sip.ClientTransaction;
|
||||||
import javax.sip.Dialog;
|
|
||||||
import javax.sip.header.CallIdHeader;
|
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
||||||
@Service
|
@Service
|
||||||
public class PlayServiceImpl implements IPlayService {
|
public class PlayServiceImpl implements IPlayService {
|
||||||
|
|
||||||
|
@ -97,7 +94,20 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
result.onCompletion(()->{
|
result.onCompletion(()->{
|
||||||
// 点播结束时调用截图接口
|
// 点播结束时调用截图接口
|
||||||
try {
|
try {
|
||||||
String path = ResourceUtils.getURL("classpath:").getPath()+"static/static/snap/";
|
String classPath = ResourceUtils.getURL("classpath:").getPath();
|
||||||
|
// System.out.println(classPath);
|
||||||
|
String path = classPath + "static/static/snap/";
|
||||||
|
if(classPath.contains("jar")) {
|
||||||
|
classPath = classPath.substring(0, classPath.lastIndexOf("."));
|
||||||
|
classPath = classPath.substring(0, classPath.lastIndexOf("/"));
|
||||||
|
path = classPath + "/snap/";
|
||||||
|
}
|
||||||
|
if (path.startsWith("file:")) {
|
||||||
|
path = path.substring(path.indexOf(":") + 1, path.length());
|
||||||
|
}
|
||||||
|
if(System.getProperty("os.name").contains("indows")) {
|
||||||
|
path = path.substring(1, path.length());
|
||||||
|
}
|
||||||
String fileName = deviceId + "_" + channelId + ".jpg";
|
String fileName = deviceId + "_" + channelId + ".jpg";
|
||||||
ResponseEntity responseEntity = (ResponseEntity)result.getResult();
|
ResponseEntity responseEntity = (ResponseEntity)result.getResult();
|
||||||
if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
@ -109,7 +119,6 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName);
|
zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(path);
|
System.out.println(path);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue