简体   繁体   中英

How can I play music successively in the background with UIWebView or WKWebView

The website implemented inside my app would play a series of mp3 files,it works well when the app is active,but when I press HOME button or lock the phone,it cannont play more than ONE song in the background,after that,app suspended. I've already tried to set different kind of AVAudioSession Category ,but of no use.

I assume you don't have audio background mode enabled. This is what Apple documentation says:

When the UIBackgroundModes key contains the audio value, the system's media frameworks automatically prevent the corresponding app from being suspended when it moves to the background. As long as it is playing audio or video content or recording audio content, the app continues to run in the background. However, if recording or playback stops, the system suspends the app.

So it seems like you just need to enable audio background mode. Here is Ray Wenderlich's tutorial on background modes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM