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