问题
I've got an app that uses text-to-speech to occasionally give verbal cues to the user. Currently I've set it up so the TTS mixes over any music that's playing in another app. Is there any way I could temporarily pause/mute music that's playing in another app while a verbal cue plays?
回答1:
You can use MPMusicPlayerController class and it's static method iPodMusicPlayer to get instance of the system (Music app) MPMusicPlayerController object. Then you can pause, play or anything else. The main condition is the other app is using iPodMusicPlayer object, the native music application player.
So you can control player only of some applications. Correct me, if I am wrong.
Here is the documentation: MPMusicPlayerController documentation
Hope it helps
来源:https://stackoverflow.com/questions/9837353/pausing-muting-background-music-in-ios