Skip to content

Commit eb74acb

Browse files
Update music.component.ts
1 parent 6fb0dd7 commit eb74acb

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/app/features/music/music.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class MusicComponent implements OnDestroy {
109109
*/
110110
playSong(url: string, song: any, isbuttonClick: boolean = false): void {
111111
if (!this.isBrowser) return;
112+
this.removeFocus();
112113
if (!this.audio) this.audio = new Audio();
113114

114115
if (this.currentSong?.url === url) {
@@ -140,6 +141,7 @@ export class MusicComponent implements OnDestroy {
140141
*/
141142
async onSongFinished(): Promise<void> {
142143
if (!this.isBrowser) return;
144+
this.removeFocus();
143145
try {
144146
const transformedData = this.transformSongData(this.currentSong, this.isCurrentSongLiked);
145147
const nextSong = await this.saavnService.suggestNextSong(transformedData);
@@ -241,6 +243,7 @@ export class MusicComponent implements OnDestroy {
241243

242244
/** Toggles the like status of a song */
243245
toggleLike() {
246+
this.removeFocus();
244247
if (this.isCurrentSongLiked) {
245248
this.userLikedSongsService.delete(this.currentSong.id);
246249
this.isCurrentSongLiked = false;
@@ -276,6 +279,7 @@ export class MusicComponent implements OnDestroy {
276279
/** Downloads a song */
277280
async downloadSong(song: any) {
278281
if (!song?.url) return;
282+
this.removeFocus();
279283

280284
try {
281285
const res = await fetch(song.url);
@@ -300,16 +304,19 @@ export class MusicComponent implements OnDestroy {
300304

301305
/** Open the player modal */
302306
openPlayerModal() {
307+
this.removeFocus();
303308
this.showPlayerModal = true;
304309
}
305310

306311
/** Close the player modal */
307312
closePlayerModal() {
313+
this.removeFocus();
308314
this.showPlayerModal = false;
309315
}
310316

311317
/** Restart current song when Previous is pressed */
312318
restartSong() {
319+
this.removeFocus();
313320
if (this.audio) {
314321
this.audio.currentTime = 0;
315322
if (this.audio.paused) {

0 commit comments

Comments
 (0)