fix: 修复部分型号关机失败的问题

This commit is contained in:
涵曦 2024-07-01 16:57:04 +00:00
parent 87b3411f5e
commit 70d9ad93cb

View File

@ -309,6 +309,7 @@ class XiaoMusic:
async def get_if_xiaoai_is_playing(self): async def get_if_xiaoai_is_playing(self):
playing_info = await self.mina_service.player_get_status(self.device_id) playing_info = await self.mina_service.player_get_status(self.device_id)
self.log.info(playing_info)
# WTF xiaomi api # WTF xiaomi api
is_playing = ( is_playing = (
json.loads(playing_info.get("data", {}).get("info", "{}")).get("status", -1) json.loads(playing_info.get("data", {}).get("info", "{}")).get("status", -1)
@ -321,11 +322,12 @@ class XiaoMusic:
if is_playing: if is_playing:
# stop it # stop it
ret = await self.mina_service.player_stop(self.device_id) ret = await self.mina_service.player_stop(self.device_id)
self.log.debug(f"force_stop_xiaoai player_stop ret:{ret}") self.log.info(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.info(f"force_stop_xiaoai player_pause ret:{ret}")
await self.stop_if_xiaoai_is_playing()
# 是否在下载中 # 是否在下载中
def is_downloading(self): def is_downloading(self):
@ -1027,11 +1029,13 @@ class XiaoMusic:
"audio_type": audio_type, "audio_type": audio_type,
} }
} }
data = {"startaudioid": audio_id, "music": json.dumps(music)}
self.log.info(json.dumps(data))
return await self.mina_service.ubus_request( return await self.mina_service.ubus_request(
deviceId, deviceId,
"player_play_music", "player_play_music",
"mediaplayer", "mediaplayer",
{"startaudioid": audio_id, "music": json.dumps(music)}, data,
) )
async def debug_play_by_music_url(self, arg1=None): async def debug_play_by_music_url(self, arg1=None):