play walkout songs
This commit is contained in:
@@ -96,6 +96,17 @@ export class SpotifyWebApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
async playTrack(trackId: string, deviceId?: string, positionMs?: number): Promise<void> {
|
||||
const endpoint = deviceId ? `/me/player/play?device_id=${deviceId}` : '/me/player/play';
|
||||
await this.request(endpoint, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
uris: [`spotify:track:${trackId}`],
|
||||
position_ms: positionMs || 0,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
async pause(): Promise<void> {
|
||||
await this.request('/me/player/pause', {
|
||||
method: 'PUT',
|
||||
|
||||
@@ -22,6 +22,7 @@ export const useSpotifyPlayback = () => {
|
||||
playbackState,
|
||||
currentTrack,
|
||||
play,
|
||||
playTrack,
|
||||
pause,
|
||||
skipNext,
|
||||
skipPrevious,
|
||||
@@ -29,11 +30,12 @@ export const useSpotifyPlayback = () => {
|
||||
refreshPlaybackState,
|
||||
isLoading,
|
||||
} = useSpotify();
|
||||
|
||||
|
||||
return {
|
||||
playbackState,
|
||||
currentTrack,
|
||||
play,
|
||||
playTrack,
|
||||
pause,
|
||||
skipNext,
|
||||
skipPrevious,
|
||||
|
||||
@@ -90,6 +90,7 @@ export interface SpotifyContextType extends SpotifyAuthState {
|
||||
logout: () => void;
|
||||
|
||||
play: (deviceId?: string) => Promise<void>;
|
||||
playTrack: (trackId: string, deviceId?: string, positionMs?: number) => Promise<void>;
|
||||
pause: () => Promise<void>;
|
||||
skipNext: () => Promise<void>;
|
||||
skipPrevious: () => Promise<void>;
|
||||
|
||||
Reference in New Issue
Block a user