Pausing/muting background music in iOS

拟墨画扇 提交于 2019-12-11 16:52:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!