🏗 Created draft for AudioService.

Not done yet...
This commit is contained in:
corner 2019-09-21 17:09:56 +02:00
parent 4fa4ba708e
commit 9af5d5d02b
2 changed files with 22 additions and 2 deletions

View File

@ -1,9 +1,29 @@
import { Injectable } from '@angular/core';
import { DataService } from './data.service';
@Injectable({
providedIn: 'root'
})
export class AudioService {
constructor() { }
player = new Audio();
currentlyPlaying;
constructor(private data: DataService) { }
play() {
this.player.play();
}
pause() {
this.player.pause();
}
setSong(id: number) {
this.data.getSong(id).subscribe((res: any) => {
this.player.src = this.data.apiUrl + '/play/' + res.result[0].path;
this.currentlyPlaying = id;
});
}
}

View File

@ -13,7 +13,7 @@ import { Observable } from 'rxjs';
})
export class DataService {
private apiUrl = 'http://localhost:673';
public apiUrl = 'http://localhost:673';
constructor(private http: HttpClient) { }
/**