Skip to content

Commit

Permalink
fix: 修复当前播放歌曲没保存的问题 #90
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Sep 10, 2024
1 parent 781e5eb commit d738540
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ def do_saveconfig(self, data):

# 把当前配置落地
def save_cur_config(self):
for did in self.config.devices.keys():
deviceobj = self.devices.get(did)
self.log.info(deviceobj.device)
if deviceobj is not None:
self.config.devices[did] = deviceobj.device
data = asdict(self.config)
self.do_saveconfig(data)
self.log.info("save_cur_config ok")
Expand Down Expand Up @@ -1000,6 +1005,8 @@ async def _playmusic(self, name):

self._playing = True
self.cur_music = name
self.device.cur_music = name

self.log.info(f"cur_music {self.cur_music}")
sec, url = await self.xiaomusic.get_music_sec_url(name)
await self.group_force_stop_xiaoai()
Expand All @@ -1020,6 +1027,7 @@ async def _playmusic(self, name):
return
sec = sec + self.config.delay_sec
await self.set_next_music_timeout(sec)
self.xiaomusic.save_cur_config()

async def do_tts(self, value):
self.log.info(f"try do_tts value:{value}")
Expand Down Expand Up @@ -1285,6 +1293,7 @@ async def set_play_type(self, play_type):
async def play_music_list(self, list_name, music_name):
self._last_cmd = "play_music_list"
self._cur_play_list = list_name
self.device.cur_playlist = list_name
self._play_list = self.xiaomusic.music_list[list_name]
self.log.info(f"开始播放列表{list_name}")
await self._play(music_name)
Expand Down

0 comments on commit d738540

Please sign in to comment.