0

我正在使用 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 {
        }
    }

}
4

1 回答 1

0

You need to set the proper background mode in your target Capabilites page. See picture below.

enter image description here

于 2014-07-01T14:16:40.920 回答