问题
I want to know -- what happens to a user's music when an AVPlayer
starts to play? Does nothing happen, does it stop, or does the action cancel itself? If so, how would I check and see if the user is playing music?
Apple's Documentation for this confused me.
回答1:
Alright, looking up the info for this, it seems that AVAudioPlayer
objects only interrupts the user's audio if the app's AVAudioSession
's category is set to Solo Ambient
, the default.
I saw this answer: App with AVPlayer plays mp4 interrupt iPod music after launched
I also saw this table in the Apple Developer documentation that explains whether or not different categories interrupt the user's music, with examples of different scenarios, including one for a game: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Sound.html#//apple_ref/doc/uid/TP40006556-CH44-SW1
In order to not interrupt the user's music, I need to set this to Ambient
.
来源:https://stackoverflow.com/questions/29858173/does-avplayer-stop-the-users-music