【发布时间】:2018-03-30 12:43:24
【问题描述】:
我们的 Ionic 3 应用程序中的 MP3 实时音频流与 ionic serve 一起正常工作,但在 Android 上提供 net::ERR_CONNECTION_REFUSED 和 iOS 上提供 NSURLConnection finished with error - code -1100 的设备上运行它。
我的播放器服务:
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 文件的 URL(例如 https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3)有效。可能问题与没有长度的直播有关,但我不知道如何解决。
【问题讨论】:
标签: html angular audio ionic2 ionic3