简体   繁体   中英

How to continue hybrid audio playing when in sleep mode in IOS Xamarin?

I have a hybrid app developed using Xamarin, using a library I created to mimic just the aspects of MVC I needed, such that I can almost share the same .cshtml files, and model and controller libraries as my web site. It's a language study app, and one part of it is a media player for playing audio lesson files, implemented in HTML 5 and JavaScript. On Android, when I put the phone to sleep, the audio will continue. In IOS, it will fade to silence right-way.

Is there a way to keep the audio playing in sleep mode?

Thanks.

Some searching revealed the following useful page: https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-walkthroughs/location-walkthrough

Since I'm using Visual Studio on a PC, I had to add the following to my info.plist:

  <key>UIBackgroundModes</key>
  <array>
    <string>audio</string>
  </array>

Note the "audio" value as opposed to "location" used in the example.

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