I recently created a function for streaming audio in Angular:
private streamObservable(url) {
new Observable(observer => {
// Play audio
this.audioObj.src = url;
this.audioObj.load();
this.audioObj.play();
const handler = (event: Event) => {
observer.next(event);
};
this.addEvents(this.audioObj, this.audioEvents, handler);
return () => {
// Stop Playing
this.audioObj.pause();
this.audioObj.currentTime = 0;
// remove event listeners
this.removeEvents(this.audioObj, this.audioEvents, handler);
};
});
}
However, when I tried using this function, I encountered an error:
Function usage:
playStream(url) {
return this.streamObservable(url).pipe(takeUntil(this.stop$));
}
The error message displayed is:
Property 'pipe' does not exist on type 'void'.
What could be the problem and how can I resolve it?