fix: 尝试修复关机失败的问题
This commit is contained in:
parent
619bb9c853
commit
80da6bd1e6
@ -307,11 +307,25 @@ class XiaoMusic:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Execption {e}")
|
self.log.error(f"Execption {e}")
|
||||||
|
|
||||||
|
async def get_if_xiaoai_is_playing(self):
|
||||||
|
playing_info = await self.mina_service.player_get_status(self.device_id)
|
||||||
|
# WTF xiaomi api
|
||||||
|
is_playing = (
|
||||||
|
json.loads(playing_info.get("data", {}).get("info", "{}")).get("status", -1)
|
||||||
|
== 1
|
||||||
|
)
|
||||||
|
return is_playing
|
||||||
|
|
||||||
|
async def stop_if_xiaoai_is_playing(self):
|
||||||
|
is_playing = await self.get_if_xiaoai_is_playing()
|
||||||
|
if is_playing:
|
||||||
|
# stop it
|
||||||
|
ret = await self.mina_service.player_stop(self.device_id)
|
||||||
|
self.log.debug(f"force_stop_xiaoai player_stop ret:{ret}")
|
||||||
|
|
||||||
async def force_stop_xiaoai(self):
|
async def force_stop_xiaoai(self):
|
||||||
ret = await self.mina_service.player_pause(self.device_id)
|
ret = await self.mina_service.player_pause(self.device_id)
|
||||||
self.log.debug(f"force_stop_xiaoai player_pause ret:{ret}")
|
self.log.debug(f"force_stop_xiaoai player_pause ret:{ret}")
|
||||||
# ret = await self.mina_service.player_stop(self.device_id)
|
|
||||||
# self.log.debug(f"force_stop_xiaoai player_stop ret:{ret}")
|
|
||||||
|
|
||||||
# 是否在下载中
|
# 是否在下载中
|
||||||
def is_downloading(self):
|
def is_downloading(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user