Spaces:
Sleeping
Sleeping
Download backend/src/modules/player/player.controller.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/player/player.controller.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/player/player.controller.ts
-
curl -L -o player.controller.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/player/player.controller.ts
3.15 kB
| import { | |
| Controller, | |
| Get, | |
| Put, | |
| Post, | |
| Body, | |
| UseGuards, | |
| Req, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; | |
| import { PlayerService } from './player.service'; | |
| import { JwtAuthGuard } from '../auth/jwt-auth.guard'; | |
| ('Player & Playback State') | |
| ('me/player') | |
| (JwtAuthGuard) | |
| () | |
| export class PlayerController { | |
| constructor(private readonly playerService: PlayerService) {} | |
| () | |
| ({ summary: 'Get current playback state (Spotify-Connect)' }) | |
| getPlayerState(() req: any) { | |
| return this.playerService.getPlayerState(req.user.userId); | |
| } | |
| ('play') | |
| ({ | |
| summary: 'Start/resume playback (enforces tier server-side)', | |
| }) | |
| play( | |
| () req: any, | |
| () body: { context_uri?: string; track_id?: string; offset?: number }, | |
| ) { | |
| return this.playerService.play(req.user.userId, body); | |
| } | |
| ('pause') | |
| ({ summary: 'Pause playback' }) | |
| pause(() req: any) { | |
| return this.playerService.pause(req.user.userId); | |
| } | |
| ('next') | |
| ({ summary: 'Skip to next track in queue' }) | |
| next(() req: any) { | |
| return this.playerService.next(req.user.userId); | |
| } | |
| ('previous') | |
| ({ summary: 'Go to previous track' }) | |
| previous(() req: any) { | |
| return this.playerService.previous(req.user.userId); | |
| } | |
| ('seek') | |
| ({ summary: 'Seek position_ms in active track' }) | |
| seek(() req: any, () body: { position_ms: number }) { | |
| return this.playerService.seek(req.user.userId, body.position_ms); | |
| } | |
| ('volume') | |
| ({ summary: 'Set volume percent for active device' }) | |
| setVolume(() req: any, () body: { volume: number }) { | |
| return this.playerService.setVolume(req.user.userId, body.volume); | |
| } | |
| ('shuffle') | |
| ({ summary: 'Toggle shuffle mode' }) | |
| toggleShuffle(() req: any) { | |
| return this.playerService.toggleShuffle(req.user.userId); | |
| } | |
| ('repeat') | |
| ({ summary: 'Set repeat mode (off / context / track)' }) | |
| setRepeat( | |
| () req: any, | |
| () body: { mode: 'off' | 'track' | 'context' }, | |
| ) { | |
| return this.playerService.setRepeat(req.user.userId, body.mode); | |
| } | |
| ('queue') | |
| ({ summary: 'Get upcoming queue' }) | |
| getQueue(() req: any) { | |
| return this.playerService.getQueue(req.user.userId); | |
| } | |
| ('queue') | |
| ({ summary: 'Add track to end of queue' }) | |
| addToQueue(() req: any, () body: { track_id: string }) { | |
| return this.playerService.addToQueue(req.user.userId, body.track_id); | |
| } | |
| ('devices') | |
| ({ | |
| summary: 'List active devices for Spotify-Connect switching', | |
| }) | |
| getDevices(() req: any) { | |
| return this.playerService.getDevices(req.user.userId); | |
| } | |
| ('transfer') | |
| ({ summary: 'Transfer playback to another registered device' }) | |
| transferPlayback(() req: any, () body: { device_id: string }) { | |
| return this.playerService.transferPlayback(req.user.userId, body.device_id); | |
| } | |
| } | |