play audio in background on intervals iOS - background

So I am working on an app that requires different audio files to be played using an NSTimer every X amount of time. Yes, it needs to play the audio in the background as well, but I have had inconsistent results trying to do so. I have searched the web thoroughly to find a solution to this problem, but I have had no luck.
I have enabled background modes and checked off item 0(audio) and made sure it was in my info.plist. I have set the "App does not run in background" key to NO in the info.plist. In the viewDidLoad method of the VC, I have set the AVAudioCategory to categoryPlayback and set the AVAudioSession to active. I have also moved these lines of code around in different places of the app to look for different results, and the best results I have gotten is that the app will continue to run in the background sometimes and at other times it will suspend.
Through all of my searching, I have seen forums explaining how to play audio in the background. However, I have not found any solutions to playing short audio files in the background intermittently on different scheduled intervals.
I know of at least one app in the App Store that is able to do this, and they use the ducking feature of AVFoundation to duck audio playing in the background(Im not sure if other frameworks are able to duck background audio, such as AudioToolbox, but I would like to have ducking enabled for my app).
If anyone knows of any legal solution for my problem, your assistance would be greatly appreciated.

Related

Playing a muted video without interrupting background music

My design calls for a video playing in the background of my login screen, exactly like 6snap has.
I would like to avoid the default behavior of stopping the user's music when the video starts to play. My video does not have sound.
I'm using:
<MediaElement Source="MyVideo.mp4" />
I tried setting IsMuted=true which didn't help. Does anyone have an idea how 6snap managed it?
Edit: currently trying the animated gif route. Using the ImageTools 3rd party library and having converted my MP4, it works fine. My 9 second 640x1136 3MB video became a 41MB GIF, so I have to reduce the quality drastically. Still trying to find a better way if possible.
You won't be able to do that with Background Audio and MediaElement, hence as MSDN says:
When a MediaElement control plays audio or video content, any background sounds or media already playing are halted. The app launches the playback experience when the user taps the control. Only one MediaElement control can operate at a time.
It's no matter you have no sound - when you start to play all background sounds/media are halted.
I'm not sure how the App you have mentioned achieved that, but maybe you can try with DirectX/XNA - thought I've not tried this and don't know if that would help.

Background modes are turned off automatically

I have set in the Info.plist, the "app require background modes", the "app registers for location updates".
I put the app to be in the background, and I do get the location delegates for a while, but after 25 minutes it stopped getting the locations.
How do I know that? Each call of the delegate, it sends the data to the server (parse) .
I am also wondering if the problem arises because the location is turned off in the background, or because I can't send data to the server at background.
Also do I have to turn on audio to keep it alive?
According to Apple, I can listen in the background with:
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
Do I have to turn on an audio? Our app needs to get data location constantly from business.
This issue is amazing. There are dozens of opinions about what you can do and what you can't do. There is no one place that tells you how you can sample background locations, and if Apple allows this.
I guess problem is with pausesLocationUpdatesAutomaticallyBy
By default LocationManager pausesLocationUpdatesAutomatically is Yes, so after some if your device is not move or not change location may OS will stop the app, so set NO for this property , and not need to turn on an audio.

start video record on view load in ios

I've looked through the Apple documentation but have seen no mention of how to do this, nevermind if it's even possible or not. I'd like to make it so that an iPhone/iPad begins video recording automatically when a certain view is loaded, and stops and saves when the view is dismissed. Is there any way that I can do this or am I just going to have to use the normal UI for video recording?
Use AVCaptureSession
https://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html#//apple_ref/occ/cl/AVCaptureSession

Is it possible to capture touch events in the background on a jailbroken iOS device?

I have an installation project in mind which involves a hacked iPad - I'd like to have a background process running recording all the touch events regardless of what app is running in the foreground, and send them out via OSC.
Note that this is using a jailbroken iPad with root access, and users will be alerted about not entering any sensitive data. But I'm not an iOS developer so I'm not sure if this is even possible. I'd appreciate any kind of input/suggestions.
[edit] Since someone questioned my motive behind this question, I'll try to explain a bit: to be specific, I'd like to build a mechanical system with Arduino that emulates the user's touch input on the iPad, but I do not want to limit them to using an app that does nothing else but recording touch events.
There are three options:
Use the IOHIDFamily subsystem to capture all the touch events. This will do most of the processing for you, the only thing you'll need to do is fetch the events using a HID client, get their types, and if they are touch events, get their position, radius and other things you need.
Use the MultitouchSupport framework. This way you will have to process the digitizer data frames manually which is tricky.
Use a MobileSubstrate hook to hook the already existing HID client inside SpringBoard.

iPhone SDK Question with Audio/Mic

I am trying to do an app, to where when it launches, it will detect audio, and then play it back automatically. NO BUTTONS, nothing to press. Just a picture of something then, it listens for audio, then plays it back. Similar to the Talking Carl app in the App Store. Any ideas/help? Would appreciate it, if i could use the code with IB.
Work through this example:
http://www.iphoneam.com/blog/index.php?title=using-the-iphone-to-record-audio-a-guide&more=1&c=1&tb=1&pb=1
And then you'll want to put the code for recording and playing back the audio in the viewDidLoad method of whichever view is your main view.
One thing you might also want to consider is how long you want it to record before it plays it back? And also, you'll want to stop recording once the sound starts playing... and also you'll want to start recording again once the sound STOPS playing.... all these things to think about and learn about :)