Skip to content

Commit

Permalink
播放歌曲指令默认播放最后一次播放的歌曲
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jun 15, 2024
1 parent f01665c commit 0874efe
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,35 @@ def match_cmd(self, query, ctrl_panel):
return ("stop", {})
return (None, None)

# 判断是否播放一下私募歌曲
def check_play_next(self):
# 当前没我在播放的歌曲
if self.cur_music == "":
return True
else:
filename = self.get_filename(self.cur_music)
# 当前播放的歌曲不存在了
if len(filename) <= 0:
return True
pass
return False

# 播放歌曲
async def play(self, **kwargs):
self._playing = True
parts = kwargs["arg1"].split("|")
search_key = parts[0]
name = parts[1] if len(parts) > 1 else search_key
if search_key == "" and name == "":
await self.play_next()
return
if name == "":
name = search_key

if search_key == "" and name == "":
if self.check_play_next():
await self.play_next()
return
else:
name = self.cur_music

self.log.debug("play. search_key:%s name:%s", search_key, name)
filename = self.get_filename(name)

Expand Down Expand Up @@ -625,7 +643,6 @@ async def stop(self, **kwargs):
if self._next_timer:
self._next_timer.cancel()
self.log.info("定时器已取消")
self.cur_music = ""
await self.force_stop_xiaoai()

async def stop_after_minute(self, **kwargs):
Expand Down

0 comments on commit 0874efe

Please sign in to comment.