0
我正在使用AudioStreamer庫。我的問題是當一首歌曲結束時,下一首歌曲必須開始流式傳輸。當應用程序處於前景時,它工作正常,但當應用程序處於後臺時,它在當前歌曲後停止。這是我的代碼:AudioStreamer不從背景開始
-(void)playNextTrack
{
[stopSongStreamer stopMark30StreamingFor:playSong];
[self destroyStreamer:YES];
}
-(void) onStopStreamingResultMark30:(BOOL) isSuccess{
[stopSongStreamer stopMArkStreamingSongFor:playSong];
}
-(void) onStopStreamingStop:(BOOL) isSuccess{
if (nextPlaySong!=nil) {
NSLog(@"play next song");
[songStreamer streamSongForObject:nextPlaySong];
nextPlaySong = nil;
}
}
-(void) onStreamingResultWith:(PSStreamingSong *)streamingSongResult{
if(streamingSongResult == nil)
{
[self handleError];
}else{
@try {
streamer=[[AudioStreamer alloc]init];
streamer.url=url;
isSongDurationUpdated=NO;
progressUpdateTimer =
[NSTimer
scheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(updateProgress:)
userInfo:nil
repeats:YES];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(playbackStateChanged:)
name:ASStatusChangedNotification
object:streamer];
[streamer start];
}
@catch (NSException *exception) {
NSLog(@"Unable to stream song...");
}
@finally {
}
}
}