From a24b17ed3c2425587758d977566eb654ce294058 Mon Sep 17 00:00:00 2001 From: lawrencehj <1934378145@qq.com> Date: Wed, 23 Jun 2021 15:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=89=93=E5=8C=85jar?= =?UTF-8?q?=E5=90=8E=E6=88=AA=E5=9B=BE=E8=B7=AF=E5=BE=84=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=88=AA=E5=9B=BETimeout=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/impl/PlayServiceImpl.java | 13 +++++++------ 1 file changed, 7 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 320cc260..540a66e9 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 @@ -96,15 +96,16 @@ public class PlayServiceImpl implements IPlayService { try { String classPath = ResourceUtils.getURL("classpath:").getPath(); // System.out.println(classPath); - String path = classPath + "static/static/snap/"; + // 兼容打包为jar的class路径 if(classPath.contains("jar")) { classPath = classPath.substring(0, classPath.lastIndexOf(".")); - classPath = classPath.substring(0, classPath.lastIndexOf("/")); - path = classPath + "/snap/"; + classPath = classPath.substring(0, classPath.lastIndexOf("/") + 1); } - if (path.startsWith("file:")) { - path = path.substring(path.indexOf(":") + 1, path.length()); + if (classPath.startsWith("file:")) { + classPath = classPath.substring(classPath.indexOf(":") + 1, classPath.length()); } + String path = classPath + "static/static/snap/"; + // 兼容Windows系统路径(去除前面的“/”) if(System.getProperty("os.name").contains("indows")) { path = path.substring(1, path.length()); } @@ -116,7 +117,7 @@ public class PlayServiceImpl implements IPlayService { StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData(); String flvUrl = streamInfoForSuccess.getFlv(); // 请求截图 - zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName); + zlmresTfulUtils.getSnap(flvUrl, 15, 1, path, fileName); } } System.out.println(path);