From ec31aa01b9883c24f17385ab30f7e2668d0a98d3 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Mon, 26 Oct 2020 23:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=9A=E6=97=B6=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=8F=8A=E6=89=8B=E5=8A=A8=E5=88=B7=E6=96=B0=E6=9B=B2?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E6=96=B9=E6=B3=95=20=E8=BF=87=E6=BB=A4png?= =?UTF-8?q?=E5=92=8Ctorrent=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/tools/home/nas/MusicController.java | 11 ++++++++++- src/main/java/com/yutou/tools/utils/MusicTools.java | 13 +++++++++++++ web/html/body/nas/music.html | 8 ++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/yutou/tools/home/nas/MusicController.java b/src/main/java/com/yutou/tools/home/nas/MusicController.java index caef6ae..3683fb5 100644 --- a/src/main/java/com/yutou/tools/home/nas/MusicController.java +++ b/src/main/java/com/yutou/tools/home/nas/MusicController.java @@ -62,12 +62,21 @@ public class MusicController { return json.toJSONString(); } + @RequestMapping("reload.do") + @ResponseBody + public String reload(){ + JSONObject json=new JSONObject(); + MusicTools.getInstance().scanMusic(); + json.put("msg","ok"); + json.put("code",0); + return json.toJSONString(); + } @RequestMapping("find/file.do") @ResponseBody public String findFile(String path){ JSONObject json=new JSONObject(); if(StringUtils.isEmpty(path)){ - json.put("code",0); + json.put("code",-1); json.put("msg","地址为空"); return json.toJSONString(); } diff --git a/src/main/java/com/yutou/tools/utils/MusicTools.java b/src/main/java/com/yutou/tools/utils/MusicTools.java index fa55455..c540886 100644 --- a/src/main/java/com/yutou/tools/utils/MusicTools.java +++ b/src/main/java/com/yutou/tools/utils/MusicTools.java @@ -11,6 +11,7 @@ import ealvatag.tag.Tag; import org.springframework.util.StringUtils; import java.io.*; +import java.text.SimpleDateFormat; import java.util.*; public class MusicTools { @@ -32,6 +33,16 @@ public class MusicTools { private MusicTools() { scanMusic(); + new Timer().schedule(new TimerTask() { + @Override + public void run() { + String time=new SimpleDateFormat("HH:mm").format(new Date()); + if(time.equals("00:00")){ + System.out.println("零点刷新列表"); + scanMusic(); + } + } + },0,10*1000); } public synchronized void scanMusic() { @@ -170,6 +181,8 @@ public class MusicTools { if (file.getName().endsWith(".lrc") || file.getName().endsWith(".jpg") || file.getName().endsWith(".ini") + || file.getName().endsWith(".png") + || file.getName().endsWith(".torrent") ) { return null; } diff --git a/web/html/body/nas/music.html b/web/html/body/nas/music.html index fe53c63..f08bfa8 100644 --- a/web/html/body/nas/music.html +++ b/web/html/body/nas/music.html @@ -32,6 +32,7 @@
+ 刷新曲库 @@ -168,10 +169,13 @@ }); $('#download').click(function () { window.open(localhost + "/nas/music/play.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&random=false&filePath=" + playNow) - }) + }); $('#next').click(function (){ playNext() - }) + }); + $('#reload').click(function (){ + $.get(localhost+"/nas/music/reload.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk") + }); function playNext() {