2
我们的Ionic 3应用中的MP3直播音频流与ionic serve
正常工作,但在Android设备上运行net::ERR_CONNECTION_REFUSED
,在iOS设备上运行NSURLConnection finished with error - code -1100
。HTML5音频直播流让设备中的连接被拒绝
我的播放器服务:
import {Injectable} from '@angular/core';
@Injectable()
export class PlayerService {
stream: any;
promise: any;
constructor() {
this.initLiveStream();
}
initLiveStream() {
this.stream = new Audio('http://audio-mp3.ibiblio.org:8000/wcpe.mp3');
}
play() {
this.stream.play();
this.promise = new Promise((resolve,reject) => {
this.stream.addEventListener('playing',() => {
resolve(true);
});
this.stream.addEventListener('error',() => {
reject(false);
});
});
return this.promise;
};
pause() {
this.stream.pause();
};
}
与URL更换现场直播的网址为MP3文件(例如https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3)的作品。可能这个问题与没有长度的直播流有关,但我无法弄清楚如何解决这个问题。
我喜欢使用本地玩家的想法,但我的应用程序使其完全阻断的功能,因为它是全屏幕。但更重要的是:mp3文件播放,但实时流给出'媒体播放器错误:未知(1)-1005' – JanP
当你在本地播放器(插件)播放实时流时出现上述错误? – Sampath
是的,它的确如此。但是我发现问题与流而不是应用有关。我尝试了荷兰非常受欢迎的广播电台(http://icecast.omroep.nl/3fm-bb-mp3),它可以在上面的代码中工作(即使使用HTML5解决方案)。 感谢您的回答。 – JanP