Skip to content
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

Merged
merged 5 commits into from
Aug 19, 2023
Merged

Conversation

Heyxk
Copy link
Contributor

@Heyxk Heyxk commented Aug 15, 2023

增加一个小爱音箱通过url播放歌曲的服务, 可以配合nas使用

Copy link
Owner

@al-one al-one left a 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来实现播放功能,可以参考:

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

@al-one al-one merged commit f59c0a5 into al-one:master Aug 19, 2023
4 of 5 checks passed
al-one added a commit that referenced this pull request Aug 19, 2023
al-one added a commit that referenced this pull request Aug 19, 2023
@al-one
Copy link
Owner

al-one commented Aug 19, 2023

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}}]

al-one added a commit that referenced this pull request Aug 19, 2023
@Heyxk
Copy link
Contributor Author

Heyxk commented Aug 21, 2023

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

@Heyxk Heyxk deleted the my branch August 21, 2023 05:05
@lhy741059930
Copy link

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_l05c_11e2_play_control

以上服务执行之后我的小爱play 增强版没有反应。是否对小爱的版本有要求

@zhyueyueniao
Copy link

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}}]

大佬,你好,这个在我的小爱art可以正常播放,但是在小爱触屏版和智能家庭屏上也什么反应都没有

@haodadajipai
Copy link

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

大佬,最近不知道是更新了什么导致的,播放音乐会一直重复播放

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants