-
-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 增加小爱音箱通过url播放歌曲的服务 #1261
feat: 增加小爱音箱通过url播放歌曲的服务 #1261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢PR!
希望通过MiotMediaPlayerEntity.play_media
来实现播放功能,可以参考:
hass-xiaomi-miot/custom_components/xiaomi_miot/media_player.py
Lines 768 to 781 in 1bf6ab6
def play_media(self, media_type, media_id, **kwargs): | |
"""Play a piece of media.""" | |
tim = str(int(time.time() * 1000)) | |
pms = { | |
'action': 'play', | |
'type': media_type, | |
'url': media_id, | |
'apikey': self._api_key, | |
'ts': tim, | |
'sign': hashlib.md5(f'mitvsignsalt{media_id}{self._api_key}{tim[-5:]}'.encode()).hexdigest(), | |
} | |
rdt = self.request_mitv_api('controller', params=pms) | |
self.logger.info('%s: Play media: %s', self.name_model, [pms, rdt]) | |
return not not rdt |
service: media_player.play_media
data:
entity_id: media_player.xiaoai_x08c_d135
media_content_type: music
media_content_id: https://click33.gitee.io/xixi/bg.mp3 在我的小爱音响上执行后没有反应🤣。 2023-08-20 02:53:17.727 INFO (MainThread) [custom_components.xiaomi_miot.media_player] 客厅触屏小爱(xiaomi.wifispeaker.x08c): Play media: [{'deviceId': '297a063e-xxxx-xxxx-xxxx-b03f006c1c48', 'path': 'mediaplayer', 'method': 'player_play_url', 'message': '{"url": "https://click33.gitee.io/xixi/bg.mp3", "type": 1, "media": "app_ios"}'}, {'code': 0, 'message': "Msg has been successfully proxy to the device, this service is a simple proxy, if you encounter any problems pls contact ROM's developers directly!!!", 'data': {'code': 0}}] |
使用下面的格式在我的小爱音箱Pro上正常播放: service: media_player.play_media
data:
media_content_id: https://click33.gitee.io/xixi/bg.mp3
media_content_type: music
target:
entity_id: media_player.xiaomi_lx06_3ec7_play_control |
以上服务执行之后我的小爱play 增强版没有反应。是否对小爱的版本有要求 |
大佬,你好,这个在我的小爱art可以正常播放,但是在小爱触屏版和智能家庭屏上也什么反应都没有 |
大佬,最近不知道是更新了什么导致的,播放音乐会一直重复播放 |
我也是这个问题,之前用media_content_id指定音频链接,播放一次就自动停止了,现在会一直重复播放。我在node-red里的音频源是随机生成的,长度不定,导致也没办法手动停止,有点难受,相当于这个play_media的功能就完全没办法用了,大佬有解决办法不? |
我直接放弃API的形式。直接解了SSH,用指令去播放了。如果你是PRO也可以看看这个拦截器:https://github.com/LGinC/xiaoai 拆机刷机看这个:https://github.com/duhow/xiaoai-patch/blob/master/research/lx06/install.md |
很久没使用过这个了,目前不太清楚什么问题。 |
增加一个小爱音箱通过url播放歌曲的服务, 可以配合nas使用