From b11c57d4b5c9c3b62e2cbea0672d8b5b0235f966 Mon Sep 17 00:00:00 2001 From: lawrencehj <1934378145@qq.com> Date: Tue, 22 Jun 2021 11:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=89=93=E5=8C=85jar?= =?UTF-8?q?=E5=90=8Esnap=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=85=BC=E5=AE=B9windows=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/impl/PlayServiceImpl.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index ec0222be..320cc260 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -24,7 +24,6 @@ import gov.nist.javax.sip.stack.SIPDialog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -32,13 +31,11 @@ import org.springframework.util.ResourceUtils; import org.springframework.web.context.request.async.DeferredResult; import javax.sip.ClientTransaction; -import javax.sip.Dialog; -import javax.sip.header.CallIdHeader; import javax.sip.message.Response; -import java.io.File; import java.io.FileNotFoundException; import java.util.UUID; +@SuppressWarnings(value = {"rawtypes", "unchecked"}) @Service public class PlayServiceImpl implements IPlayService { @@ -97,7 +94,20 @@ public class PlayServiceImpl implements IPlayService { result.onCompletion(()->{ // 点播结束时调用截图接口 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"; ResponseEntity responseEntity = (ResponseEntity)result.getResult(); if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { @@ -109,7 +119,6 @@ public class PlayServiceImpl implements IPlayService { zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName); } } - System.out.println(path); } catch (FileNotFoundException e) { e.printStackTrace();