Skip to content

一起听 - 心跳

维持一起听播放状态的心跳接口。路由名沿用历史拼写 heatbeat

接口信息

项目
接口地址/listentogether/heatbeat
请求方式GET / POST
需要登录
对应模块listentogether_heatbeat
文档分类一起听
上游路径/api/listen/together/heartbeat

请求参数

参数类型必填默认值说明
roomIdstring-房间 ID
songIdstring-当前播放歌曲 ID
playStatusstring-播放状态,常见为 PLAYPAUSE
progressnumber-当前播放进度,单位毫秒

HTTP 示例

bash
POST /listentogether/heatbeat?roomId=MzA0NjY5...&songId=1372188635&playStatus=PLAY&progress=0

编程式调用

ts
import { listentogetherHeatbeat } from 'hana-music-api'

const result = await listentogetherHeatbeat({
  roomId: 'MzA0NjY5...',
  songId: '1372188635',
  playStatus: 'PLAY',
  progress: 0,
})

console.log(result.body)

返回关注点

  • code: 是否上报成功。
  • message: 心跳失败时的错误原因。

相关接口

Released under the MIT License.