1

In Rad Studio, we have the TMedialPlayer control that can play audio. This thread shows to keep the audio playing after the user locks the screen (Project->Options->Version Info-> UIBackgroundModes set to audio).

However, we have no ability to invoke the iOS audio controls (pause, play) on lock screen. Apple will reject any app that plays audio in the background without displaying the audio controls on lock screen and in control center (Apple documentation on controlling background audio).

Anyone have any good ideas on how this can be achieved (using C++ FMX)?

Can the functions mentioned on that Apple documentation page be called from FMX app?

Is there a third party medial control with this capability (to show the apple audio controls)?

Ken White
  • 123,280
  • 14
  • 225
  • 444
relayman357
  • 793
  • 1
  • 6
  • 30
  • I posted about this on Embarcadero's [Idera community](https://community.idera.com/developer-tools/) and in one response a guy said his app was just rejected by Apple with comment, "While in background, the audio cannot be paused or resumed." Hopefully we will have a solution soon... – relayman357 Mar 01 '19 at 15:15
  • This [Embarcadero page](https://community.idera.com/developer-tools/b/blog/posts/building-stunning-uis-with-c-and-firemonkey) says we can access native platform APIs with JNI Bridge for Android and Objective C Bridge on iOS. Is that a possibility here? – relayman357 Mar 03 '19 at 02:38
  • 1
    Yes, the iOS Objective-C bridge can be used in C++. See [Objective-C Bridge on iOS (FMX)](https://community.idera.com/developer-tools/platforms/f/ios-platform/68816/objective-c-bridge-on-ios-fmx) in Embarcadero's forum. – Remy Lebeau Feb 11 '20 at 17:25
  • 1
    I've done the equivalent in Delphi in a test project, here: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/RemoteCommandCenterDemo.zip. I'm not a C++Builder guy, so perhaps someone else can help with making it work there – Dave Nottage Feb 12 '20 at 09:10
  • @Dave - your code works great in Delphi. How can I extend it to set the metadata (e.g. name of song playing)? – relayman357 Mar 05 '20 at 14:18
  • 1
    @relayman357 It would involve extracting the metadata from the file being played and updating the nowPlayingInfo member of MPNowPlayingInfoCenter. The dictionary seems to be a simple key/value arrangement using the MPMediaItemPropertyXXXX keys. I'm a bit time stretched for a while, so I'm unable to update it for now. – Dave Nottage Mar 05 '20 at 21:44
  • Hi Dave - if you get the free time, you could skip the part about extracting the meta-data as I would already know the name of the file. – relayman357 Apr 23 '20 at 19:46

0 Answers0