Skip to content

一起听 - 播放指令

向房间广播当前播放器动作,例如播放、暂停、切歌和同步进度。

接口信息

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

请求参数

参数类型必填默认值说明
roomIdstring-房间 ID
commandTypestring-指令类型。示例页中可见 PLAYPAUSEGOTOseek
targetSongIdstring-指令目标歌曲 ID
clientSeqnumber-客户端维护的递增序号
playStatusstring-播放状态,常见为 PLAYPAUSE
formerSongIdstring-上一首歌曲 ID;示例页未知时传 -1
progressnumber0当前进度,单位毫秒

HTTP 示例

bash
POST /listentogether/play/command?roomId=MzA0NjY5...&commandType=PLAY&targetSongId=1372188635&clientSeq=1&playStatus=PLAY&progress=0

编程式调用

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

const result = await listentogetherPlayCommand({
  roomId: 'MzA0NjY5...',
  commandType: 'GOTO',
  targetSongId: '1372188635',
  formerSongId: '-1',
  clientSeq: 2,
  playStatus: 'PLAY',
  progress: 15342,
})

console.log(result.body)

返回关注点

  • code: 是否上报成功。
  • message: 失败时的错误信息。

补充说明

相关接口

Released under the MIT License.