current track on wait

This commit is contained in:
_Bastler 2022-01-03 12:56:29 +01:00
parent eb6e3f93ba
commit 329e4acccb
3 changed files with 19 additions and 0 deletions

View File

@ -59,6 +59,16 @@
<mat-card-title>{{'jukebox' | i18n}}</mat-card-title>
<mat-card-subtitle>{{'jukebox.wait' | i18n}}</mat-card-subtitle>
</mat-card-header>
<mat-card-title-group *ngIf="currentTrack">
<img *ngIf="getImageUrl(currentTrack)" mat-card-sm-image [src]="getImageUrl(currentTrack)">
<mat-card-title><small>{{'jukebox.current' | i18n}}</small></mat-card-title>
<mat-card-title>{{currentTrack.name}}</mat-card-title>
<mat-card-subtitle>
<span *ngFor="let artist of currentTrack.artists; let i = index">
{{artist.name}}<span *ngIf="(i+1) < currentTrack.artists.length">, </span>
</span>
</mat-card-subtitle>
</mat-card-title-group>
<mat-card-content>
<p *ngIf="timeout">{{'jukebox.timeout' | i18n:timeout}}</p>
</mat-card-content>

View File

@ -62,6 +62,11 @@ export class JukeboxComponent implements OnInit {
} else if (error.status == 402) {
this.wait = true;
this.timeout = 60 - error.error;
this.jukeboxService.current().subscribe((response) => {
this.currentTrack = response;
});
this.timer = setInterval(() => {
this.timeout--;
if (this.timeout == 0) {

View File

@ -23,6 +23,10 @@ export class JukeboxService {
return this.http.get(environment.apiUrl + "/jukebox/search?q=" + query + "&offset=" + offset);
}
current() {
return this.http.get(environment.apiUrl + "/jukebox/current");
}
queue(uri: string) {
return this.http.post(environment.apiUrl + "/jukebox/queue?uri=" + uri, "");
}