🏗 Created draft for AudioService.
Not done yet...
This commit is contained in:
parent
4fa4ba708e
commit
9af5d5d02b
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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) { }
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user