Skip to content

Commit

Permalink
fix: 修复M01语音播放问题,X08C X08E X8F 型号默认采用型号兼容模式 see #30
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Dec 3, 2024
1 parent 742929b commit 8c92afd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions xiaomusic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@
GET_ASK_BY_MINA = {
"M01",
}

# 需要使用 play_musci 接口的设备型号
NEED_USE_PLAY_MUSIC_API = {
"X08C",
"X08E",
"X8F",
}
6 changes: 4 additions & 2 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
COOKIE_TEMPLATE,
GET_ASK_BY_MINA,
LATEST_ASK_API,
NEED_USE_PLAY_MUSIC_API,
PLAY_TYPE_ALL,
PLAY_TYPE_ONE,
PLAY_TYPE_RND,
Expand Down Expand Up @@ -187,7 +188,7 @@ async def poll_latest_ask(self):
self.last_timestamp[did] = int(time.time() * 1000)

hardware = self.get_hardward(device_id)
if hardware in GET_ASK_BY_MINA or self.config.get_ask_by_mina:
if (hardware in GET_ASK_BY_MINA) or self.config.get_ask_by_mina:
tasks.append(self.get_latest_ask_by_mina(device_id))
else:
tasks.append(
Expand Down Expand Up @@ -1711,14 +1712,15 @@ async def play_one_url(self, device_id, url, name):
ret = None
try:
audio_id = await self._get_audio_id(name)
hardware = self.get_hardward(device_id)
if self.config.continue_play:
ret = await self.xiaomusic.mina_service.play_by_music_url(
device_id, url, _type=1, audio_id=audio_id
)
self.log.info(
f"play_one_url continue_play device_id:{device_id} ret:{ret} url:{url} audio_id:{audio_id}"
)
elif self.config.use_music_api:
elif self.config.use_music_api or (hardware in NEED_USE_PLAY_MUSIC_API):
ret = await self.xiaomusic.mina_service.play_by_music_url(
device_id, url, audio_id=audio_id
)
Expand Down

0 comments on commit 8c92afd

Please sign in to comment.