AppComponent.ts
this.events.subscribe('play', () => {
this.player.play('http://streaming.livecenter.com.br:9322/;stream.mp3').then(() => {
console.log('Playing');
});
this.storage.set('button', 'play');
});
this.events.subscribe('stop', () => {
this.player.pause();
this.storage.set('button', 'stop');
console.log('STOP')
});
player.ts
play(streamUrl) {
try {
let src = streamUrl + '/;stream.mp3';
this.stream = new Audio(src);
this.stream.play();
this.promise = new Promise((resolve, reject) => {
this.stream.addEventListener('playing', () => {
resolve(true);
});
this.stream.addEventListener('error', () => {
reject(false);
});
});
return this.promise;
} catch (error) {
console.log("erro ao carregar a playlist");
}
};
pause() {
if (this.stream != null) {
this.stream.pause();
this.stream.currentTime = 0;
this.stream.src = "";
}
};