Turn off mic in iphone - iphone

I am using openEars to detect speech. It takes one second of silence to detect the end of command.
What I want is to disable the microphone for 1 second.
Can anyone tell me that how to disable mic for 1 second?

As already said in How to mute mic while Recording using UIImagePickerController? :
If you want your app to be in app store , then there is no apple
approved method to actually mute whole iPhone.There are certain
libraries but they are not approved.
Apple's documentation on Audio Session
According to the documentation you can only ask the user to have the
phone silenced physically and you can respond to certain audio changes
such as other sounds,phone calls, email sounds but you cannot mute
programmatically.
Also See this Documentation on Programming in iPhone See the part 3.3
for Audio.(Events that can be accessed and performed in iOS).
Regards,

Related

Multipeer Connectivity audio streaming stop work on background

I'm doing some audio streaming with iOS 7's Multipeer Connectivity framework. The streaming works well, but when I put the app on background it stops working.
Someone can tell me if this is a framework limitation, or I'm doing something wrong?
And, if it is a framework limitation, is it possible to do something to avoid this?
Can I use Background Tasks, to keep streaming and music working on background?
Is possible do this? If is not possible, do any alternatives exist for MultiPeer audio streaming between iOS devices?.
I´m using this example: https://github.com/tonyd256/TDAudioStreamer.
Explained on this page: http://robots.thoughtbot.com/streaming-audio-to-multiple-listeners-via-ios-multipeer-connectivity.
Thanks a lot!
On the Apple documentation for playing audio in the background (scroll down a bit). Some relevant paragraphs:
When the UIBackgroundModes key contains the audio value, the system’s media frameworks automatically prevent the corresponding app from being suspended when it moves to the background. As long as it is playing audio or video content or recording audio content, the app continues to run in the background. However, if recording or playback stops, the system suspends the app.
You can use any of the system audio frameworks to work with background audio content, and the process for using those frameworks is unchanged.
This means that iOS should recognize that you're playing audio through Core Audio, and keep your app unsuspended, as long as you've correctly configured your app for playing audio in the background.
Because your app is not suspended while playing media files, callbacks operate normally while your app is in the background. In your callbacks, though, you should do only the work necessary to provide data for playback. For example, a streaming audio app would need to download the music stream data from its server and push the current audio samples out for playback. Apps should not perform any extraneous tasks that are unrelated to playback.
You should be able to operate normally as long as your app is still playing audio, and is allowed to do what it needs to in order to continue playing audio. This means that you should be able to continue to use MPC in the background to receive the audio data and play it.
Be sure to read the entire documentation on the subject, especially regarding Audio Sessions.
iOS devices get limited cpu cycles for explicit purposes when they have been backgrounded by the user.
According to Apple's documentation on multitasking and execution in the background, the following types of apps are supported, but have to be explicitly declared:
Apps that play audible content to the user while in the background, such as a music player app
Apps that record audio content while in the background.
Apps that keep users informed of their location at all times, such as a navigation app
Apps that support Voice over Internet Protocol (VoIP)
Apps that need to download and process new content regularly
Apps that receive regular updates from external accessories
Your case falls under Apps that play audible content to the user while in the background, such as a music player app. You can find more information from the link provided above.

Not include functionality that requires that mode to run persistently (key App plays audio)

I have my v 1.1 of my app (iphone) which has been rejected from Apple.
Reasons for rejection:
2.16
We found that your app uses a background mode but does not include
functionality that requires that mode to run persistently. This
behavior is not in compliance with the App Store Review Guidelines.
We noticed your app declares support for audio in the
UIBackgroundModes key in your Info.plist, but no audible content is
played when the application is in the background. While your intention
may have been to provide this functionality, at the time of review, we
were not able to play background audio for your app.
As indicated in the iOS Application Programming Guide: "This key is
intended for use by applications that provide audible content to the
user while in the background, such as music-player or streaming-audio
applications." Therefore, it would be appropriate to provide audible
content to the user while the app is in the background or remove the
"audio" setting from the UIBackgroundModes key.
In the v 1.0 which has been accepted the required background mode "App audio plays" was already enable.
When I launch one sound of my app the sound is played and I when click on the lock screen the sound continues to be played in background.
In the new version (v1.1) I added the function which detects when I push the button Home of the iPhone. If the button home is pressed so the sound is paused.
When i try on my device it's run correctly and without bug.
So I don't understand exactly what is the problem with my app?
If you're pausing the sound when you hit the home button, then you aren't playing a sound in the background. Either change your app so that it plays sound in the background all the time, or email Apple and explain that your app needs the background functionality so that it can play while the phone is locked.
I'm not sure but you might be able to play the sound during the lock screen without audio background mode. Try removing it and see if your app behaves the same. If it does, then you should remove the key (no reason to have it).
If you use the audio background mode, your app has to play continuous audio (like the Music app, or Downcast for example). Is that what yours does? Or does it just play a sound briefly?
You should be able to play a short sound (< 10 mins) by using beginBackgroundTaskWithExpirationHandler: (I think!)
See below the answer to my Question from Apple :
Jul 31, 2012 10:21 AM. From Apple.
Hello,
Thank you for providing this information. However, in order to ensure that the audio background feature is properly implemented, it would be appropriate to press on the home button once the audio is launched.
For more information on how to implement this feature, please refer to iOS Application Programming Guide
Please make necessary change to resolve this issue.

Recording from radio streaming xcode 4

I'm building an iPhone app which play some radio over internet ..
I want to make user able to record audio from my application to the radio channel he wants ..
what framework I must use .. and what code for implementation please ?
all Regards
Unfortunately, there is no way to directly capture from the "audio bus". You can either capture the audio via the internal microphone or headset microphone, but that's it. If you are rendering the audio, you could obviously also write that audio out to a file as well at the same time. That's pretty much your only option.

On iPhone, how do you allow another app to keep running in the background while your app is running?

For example, if I start a song in Pandora and then open Safari to browse the web the Pandora song will keep playing. However, if I start a song in Pandora and then open my app it kills the Pandora song. How do I let Pandora keep playing while my app is running?
You need to tell the iOS system what behavior it should use to integrate the two audio sessions. By default it cancels the background audio when you use audio. But this behavior can be modified as described in the AVAudioSession docs here.
To quote:
Working with Music Players
To play audio from a user’s iPod library along with your own sounds
(as described in iPod Library Access Programming Guide), you must use
a so-called mixable category configuration for your audio session.
There are two, alternative ways to configure an audio session as
mixable:
Use the AVAudioSessionCategoryAmbient (or the equivalent
kAudioSessionCategory_AmbientSound) category—which is always mixable.
Use the mixable category override property
kAudioSessionProperty_OverrideCategoryMixWithOthers, as described in
“Fine-Tuning the Category,” to make an otherwise nonmixable playback
category mixable. Having used one of these options, your sounds will
not interrupt a music player—and neither will a music player’s sounds
interrupt yours.
There are two reasons why your app might "kill" the background app:
It starts to play music of its own
You use too much memory for it to keep playing and the OS closes the background app
There is no special option you need to select; you just need to be a "good citizen."

How can I record currently playing audio on the iPhone?

I'd like to record what the iPhone is currently outputting. So I'm thinking about recording audio from Apps like Music (iPod), Skype, any Radio Streaming App, Phone, Instacast... I don't want to record my own audio or the mic input.
Is there an official way to do this? How do I do it? It seems like AVAudioRecorder does not allow this, can somebody confirm?
Officially you can't. The audio stream belongs to the app playing it ,and iOS.
The Sandbox paradigm means that a resource owned by your App can't be used by another App. Resource here means Audio/Video stream or file. Exceptions are when a mediator like Document interaction controller are used.
If you want to do this you'd have to start with deducing AVFoundation's private methods and find out if theres a way there. Needless to say this it wouldn't be saleable on the App store and will probably only be possible on a jailbreak.
Good Luck.
TLDR;
This is only feasible only from time to time, as it's a time expensive process.
You can record the screen while listening your songs on Spotify, Music or whatever music application.
This will generate a video on your Photos application. That video can be converted on MP3 from your computer.
Actually, this is not true. The screen recordings will not actually have the audio from Apple Music at all, as it blocks it. Discord also uses this pipe as well, so you cannot record Discord audio either this way.