即使用户锁定手机,我也需要继续播放。我在互联网上看到了一些解决方案,但它们似乎都不起作用,例如:
AudioSessionSetActive(true);
// Set up audio session, to prevent iPhone from deep sleeping, while playing sounds
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (
kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory
);
我包括AVFoundation
,AudioToolbox
和MediaPlayer
.