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-title>{{'jukebox' | i18n}}</mat-card-title>
<mat-card-subtitle>{{'jukebox.wait' | i18n}}</mat-card-subtitle> <mat-card-subtitle>{{'jukebox.wait' | i18n}}</mat-card-subtitle>
</mat-card-header> </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> <mat-card-content>
<p *ngIf="timeout">{{'jukebox.timeout' | i18n:timeout}}</p> <p *ngIf="timeout">{{'jukebox.timeout' | i18n:timeout}}</p>
</mat-card-content> </mat-card-content>

View File

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

View File

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