0

我正在开发一个基于音频的应用程序。音频在后台播放,但当轨道改变时它会停止。当我再次打开应用程序时,它会恢复并播放下一首曲目。

我在我的应用程序中使用音频流媒体

当应用程序在前台时一切正常。请提前帮我解决这个问题。

4

2 回答 2

1

您必须将Required background modes模式添加到info.plist并添加模式App plays audio

于 2012-02-13T12:18:32.800 回答
0

尝试在您的应用程序委托中添加这些行 -

//enable remote control event for app
    if([[UIApplication sharedApplication]  respondsToSelector:@selector(beginReceivingRemoteControlEvents)])
        [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

    // allows you to play in the background when app is suspended in iOS4
    [[AVAudioSession sharedInstance] setDelegate: self];
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:nil];
于 2012-02-13T12:18:21.273 回答