import { PlayType } from './constants/constants'; export interface IAppDevSdk { requestApi: (Action: string, payload?: any) => Promise; on(eventType: string, callback: ({ deviceId, deviceData }: { deviceId: string; deviceData: any; }) => void): any; } export interface KugouResponse { error_code: number; error_msg: string; data: any; } declare abstract class TMESdk { protected appDevSdk: IAppDevSdk; protected config: { timeout: number; }; protected defaultDeviceId: string; protected constructor(appDevSdk: IAppDevSdk); /** * 设备上报回调 */ onWsReport(): void; /** * 请求token api */ requestTokenApi(Action: string, params?: any): Promise; /** * 请求酷狗 API(透传) */ requestTMEApi(action: string, KugouParams: any, deviceId?: string): Promise; /** * 控制设备 */ controlDeviceData(data: any, deviceId?: string): Promise; /** * 激活设备 */ activateDevice(deviceId: string): Promise; /** * 登录=>1.通过设备ID获取ticket */ getKugouTicket(deviceId: string): Promise; /** * 登录=>2.auth_code 换 token */ getTokenByAuthCode(authCode: string, deviceId: string): Promise; /** * 登录=>3.登录态同步Iot云端 */ syncIotUserInfo(KugouToken: string, KugouUserId: string, TokenExpire: number, deviceId: string): Promise; /** * 登录=>4.下发行为action 设备端刷新token */ deviceFreshTokenAction(deviceId: string): Promise; /** * 酷狗播控方法 * @param deviceData * @param deviceId * @private */ controlKugouDeviceData(deviceData: any, deviceId: string): Promise; /** * 获取用户信息 */ getUserInfo(deviceId: string): Promise; /** * 用户登出 */ logout(deviceId: string): Promise; /** * 校验设备授权 */ checkDeviceAuth(deviceId: string): Promise; /** * 播放音乐 */ play(deviceId: string): Promise; /** * 暂停播放 */ pause(deviceId: string): Promise; /** * 上一首 */ preSong(deviceId: string): Promise; /** * 下一首 */ nextSong(deviceId: string): Promise; /** * 设置播放模式 */ setPlayMode(playMode: number, deviceId: string): Promise; /** * 设置音量 */ setVolume(volume: any, deviceId: string): Promise; /** * 设置播放进度 */ setPlayPosition(playPosition: any, deviceId: string): Promise; /** * 设置播放质量 */ setPlayQuality(recommendQuality: any, deviceId: string): Promise; /** * 设置当前播放歌曲 */ setCurSongId(songId: any, deviceId: string): Promise; /** * 设置当前播放歌曲下标 */ setSongIndex(songIndex: any, deviceId: string): Promise; /** * 设置当前播放歌单 */ setCurrentPlayQueue(playType: PlayType, params: any, deviceId: string): Promise; /** * 获取当前播放歌单 */ getCurrentPlayQueue(deviceId: string): Promise; /** * 获取当前播放歌曲 */ getCurrentPlaySong(deviceId: string): Promise<{ error_code: number; error_msg: string; data: any; }>; /** * 获取歌曲详情 */ getSongDetail(songId: string, deviceId: string): Promise<{ error_code: number; error_msg: string; data: any; }>; /** * 获取歌单详情 */ getPlaylistDetail(action: string, params: {}, deviceId: string): Promise; /** * 播放歌曲 * @param songId 播放歌曲的id * @param songIndex 播放歌曲在列表中位置 从0开始 * @param newQueueId 播放列表id * @param newQueueType 播放列表类型 PlayType * @param deviceId */ playSong({ songId, songIndex, newQueueId, newQueueType, deviceId, }: { songId: string; songIndex: number; newQueueType: PlayType; newQueueId?: string | number; deviceId: string; }): Promise<{ error_code: number; error_msg: string; }>; getDeviceData(deviceId: string): Promise; /** * 解析 CUR_PLAY_LIST */ private getParseCurPlayList; abstract login(deviceId: string): void; } export default TMESdk;