[英]How to resume spotify player playback after interrupt when app is in background?
我有一個播放Spotify曲目的應用程序。 當應用移至后台時,它可以完美運行,但是當它被“調用”或“ iOS彈出窗口”打斷時,它將停止播放。 我在.plist中為App plays audio
添加了Required background modes
。 當應用程序在后台中斷結束后如何恢復播放。
我已經使用了音頻中斷回調。
AudioSessionInitialize (NULL, NULL, interruptionListenerCallback,self);
AudioSessionSetActive(YES);
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
並在收到中斷后,調用播放管理器的播放/暫停方法。
void interruptionListenerCallback (void *inUserData, UInt32 interruptionState)
{
// This callback, being outside the implementation block, needs a reference
//to the AudioPlayer object
CustomPlayerView *controller = (__bridge CustomPlayerView *) inUserData;
if (interruptionState == kAudioSessionBeginInterruption)
{
[controller.playbackManager setIsPlaying:NO];
}
else if (interruptionState == kAudioSessionEndInterruption)
{
[controller.playbackManager setIsPlaying:YES];
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.