[spotify-web-playback-sdk] Extend Image interface with width and height properties (#40120)

* [spotify-web-playback-sdk] Extend Image interface with width and height properties

* [spotify-web-playback-sdk] Extend Image interface with width and height properties, implement review suggestion
This commit is contained in:
Hanna Becker
2019-11-05 14:48:23 -08:00
committed by Nathan Shively-Sanders
parent 408c37f3e3
commit 57a96850d4
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -4,6 +4,7 @@
// Marcus Weiner <https://github.com/mraerino>
// Moritz Gunz <https://github.com/NeoLegends>
// Daniel Almaguer <https://github.com/deini>
// Hanna Becker <https://github.com/hanna-becker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -33,7 +34,9 @@ declare namespace Spotify {
type ErrorTypes = 'account_error' | 'authentication_error' | 'initialization_error' | 'playback_error';
interface Image {
height?: number | null;
url: string;
width?: number | null;
}
interface PlaybackContext {
@@ -32,6 +32,10 @@ player.getCurrentState().then((playbackState: Spotify.PlaybackState | null) => {
if (playbackState) {
const { current_track, next_tracks } = playbackState.track_window;
const repeatMode: 0 | 1 | 2 = playbackState.repeat_mode;
const images = current_track.album.images;
if (images.length) {
const { 0: { height, width } } = images;
}
console.log("Currently Playing", current_track);
console.log("Playing Next", next_tracks[0]);