-->

play an audio file during the call

2020-07-24 07:06发布

问题:

I am having the following requirement to be implemented into my application

I want to play an audio file after answering the call / after making a call from my application.i mean that i want to fake the caller to pretend to be in traffic / rain by playing the audio file on call..

Please provide me your insights

Thanks a lot for your views and help

回答1:

You should read the Audio Session Programming Guide, your requirements are impossible to meet. On receiving phone calls or on system alarms your audio session is interrupted. There is no way around it. Your application cannot play sound during the call. It does not kill your app however, you can get notifications on interruption begin/end so as to react gracefully. Relevant bit of the document (in "Handling Audio Interruptions"):

Adding audio session code to handle interruptions ensures that your application’s audio continues behaving gracefully when a phone call arrives or a Clock or Calendar alarm sounds.

An audio interruption is the deactivation of your application’s audio session—which immediately stops or pauses your audio, depending on which technology you are using. Interruptions happen when a competing audio session from a built-in application activates and that session is not categorized by the system to mix with yours. After your session goes inactive, the system sends a “you were interrupted” message which you can respond to by saving state, updating the user interface, and so on.



回答2:

This could certainly be done. The app would have to be a phone app first, (like the green one with the white phone in the center on iPhone) and a sound board added in the same app. A "sample" button system would be the secondary feature of this app. You could pull the phone away from your ear during a live call, finger-slide the screen with "end call" off to the side and expose your "sample board" and select an audio file to be played over your phone call. You could tap mute first so the listener only heard your audio file.



回答3:

I don't think the app store will allow this type of app.

Would be fun though ;-)



回答4:

This is not just a matter of app store, you just can not do it programmatically (Assuming that the iPhone is not jailbroken) as the call kills any other process that runs by any "not apple" app. I do agree about the fun tough :)



标签: iphone ios ios4