Skip to content

Commit 3bce59c

Browse files
committed
[ 1.0.32 ] * Fixed issue with random track playing if shuffle mode was on while selecting a track favorite. To fix, I had to disable shuffle prior to starting play of the track as the Spotify Web API would always play a shuffled track. The only other alternative was to just play 1 track, which would then end play when the song ended.
* Fixed play button icon sizing when player is idle.
1 parent 3ee7d76 commit 3bce59c

File tree

8 files changed

+67
-20
lines changed

8 files changed

+67
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Change are listed in reverse chronological order (newest to oldest).
66

77
<span class="changelog">
88

9+
###### [ 1.0.32 ] - 2025/01/17
10+
11+
* Fixed issue with random track playing if shuffle mode was on while selecting a track favorite. To fix, I had to disable shuffle prior to starting play of the track as the Spotify Web API would always play a shuffled track. The only other alternative was to just play 1 track, which would then end play when the song ended.
12+
* Fixed play button icon sizing when player is idle.
13+
914
###### [ 1.0.31 ] - 2025/01/14
1015

1116
* Renamed theming variable `--spc-medialist-items-color` to `--spc-media-browser-items-color` to more closely align with new theme naming standards.

src/components/player-body-queue.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,22 @@ export class PlayerBodyQueue extends PlayerBodyBase {
218218

219219
// build track uri list from media list.
220220
const { uris } = getMediaListTrackUrisRemaining(this.queueInfo?.queue as ITrack[], item);
221-
222-
// play media item.
223-
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","));
224-
this.progressHide();
221+
222+
// if shuffle enabled then disable it, as we want to play the selected track first.
223+
if (this.player.attributes.shuffle == true) {
224+
await this.store.mediaControlService.shuffle_set(this.player, false);
225+
}
226+
227+
// give the shuffle disable time to process.
228+
setTimeout(() => {
229+
230+
// play the selected track, as well as the remaining tracks.
231+
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","));
232+
233+
// hide progress indicator.
234+
this.progressHide();
235+
236+
}, 250);
225237

226238
} else {
227239

src/components/player-controls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class PlayerControls extends LitElement {
100100
<ha-icon-button @click=${() => this.onClickAction(REPEAT_SET)} hide=${this.hideFeature(REPEAT_SET)} .path=${this.getRepeatIcon()} label="Repeat" style=${this.styleIcon(colorRepeat)} ></ha-icon-button>
101101
<ha-icon-button @click=${() => this.onClickAction(PLAY_QUEUE)} hide=${this.hideFeature(PLAY_QUEUE)} .path=${mdiPlaylistMusic} label="Play Queue Information" style=${this.styleIcon(colorQueueItems)} ></ha-icon-button>
102102
</div>
103-
<div class="iconsIdle" hide=${idle}>
103+
<div class="iconsPower" hide=${idle}>
104104
<ha-icon-button @click=${() => this.onClickAction(PLAY)} hide=${this.hideFeature(PLAY)} .path=${mdiPlay} label="Play" style=${this.styleIcon(true)}></ha-icon-button>
105105
</div>
106106
<spc-player-volume hide=${stopped} .store=${this.store} .player=${this.player} class="player-volume-container"></spc-player-volume>

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { css } from 'lit';
22

33
/** current version of the card. */
4-
export const CARD_VERSION = '1.0.31';
4+
export const CARD_VERSION = '1.0.32';
55

66
/** SpotifyPlus integration domain identifier. */
77
export const DOMAIN_SPOTIFYPLUS = 'spotifyplus';

src/sections/recent-browser.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,21 @@ export class RecentBrowser extends FavBrowserBase {
127127
// build track uri list from media list.
128128
const { uris } = getMediaListTrackUrisRemaining(this.mediaList || [], mediaItem);
129129

130-
// play media item.
131-
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","));
130+
// if shuffle enabled then disable it, as we want to play the selected track first.
131+
if (this.player.attributes.shuffle == true) {
132+
this.store.mediaControlService.shuffle_set(this.player, false);
133+
}
132134

133-
// show player section.
134-
this.store.card.SetSection(Section.PLAYER);
135+
// give the shuffle disable time to process.
136+
setTimeout(() => {
137+
138+
// play the selected track, as well as the remaining tracks.
139+
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","));
140+
141+
// show player section.
142+
this.store.card.SetSection(Section.PLAYER);
143+
144+
}, 250);
135145

136146
}
137147
catch (error) {

src/sections/track-fav-browser.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,21 @@ export class TrackFavBrowser extends FavBrowserBase {
125125
// build track uri list from media list.
126126
const { uris } = getMediaListTrackUrisRemaining(this.mediaList || [], mediaItem);
127127

128-
// play media item.
129-
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","));
128+
// if shuffle enabled then disable it, as we want to play the selected track first.
129+
if (this.player.attributes.shuffle == true) {
130+
this.store.mediaControlService.shuffle_set(this.player, false);
131+
}
130132

131-
// show player section.
132-
this.store.card.SetSection(Section.PLAYER);
133+
// give the shuffle disable time to process.
134+
setTimeout(() => {
135+
136+
// play the selected track, as well as the remaining tracks.
137+
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","));
138+
139+
// show player section.
140+
this.store.card.SetSection(Section.PLAYER);
141+
142+
}, 250);
133143

134144
}
135145
catch (error) {

src/sections/userpreset-browser.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,22 @@ export class UserPresetBrowser extends FavBrowserBase {
218218
this.alertInfo = "Playing recommended tracks ...";
219219
this.requestUpdate();
220220

221-
// play recommended tracks.
222-
const device_id = this.player.attributes.source || null;
223-
await this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","), null, device_id);
221+
// if shuffle enabled then disable it, as we want to play the selected track first.
222+
if (this.player.attributes.shuffle == true) {
223+
await this.store.mediaControlService.shuffle_set(this.player, false);
224+
}
224225

225-
// show player section.
226-
this.store.card.SetSection(Section.PLAYER);
226+
// give the shuffle disable time to process.
227+
setTimeout(() => {
228+
229+
// play recommended tracks.
230+
const device_id = this.player.attributes.source || null;
231+
this.spotifyPlusService.PlayerMediaPlayTracks(this.player.id, uris.join(","), null, device_id);
232+
233+
// show player section.
234+
this.store.card.SetSection(Section.PLAYER);
235+
236+
}, 250);
227237

228238
}
229239
catch (error) {

src/utils/media-browser-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export function getMediaListTrackUrisRemaining(
360360
// if not a dupllicate, then add item to return list.
361361
if (!isDuplicate) {
362362
uris.push(item.uri);
363-
names.push(item.name);
363+
names.push(item.name + " (id=" + item.id + ")");
364364
count += 1;
365365
if (count >= (maxItems || 50)) {
366366
break;

0 commit comments

Comments
 (0)