How to create red header while recording in an app - iphone

In the default Voice Recording app on the iPhone, starting to record turns the iPhone header red and starts a timer. Is this something that we can reproduce in an app, or perhaps this is behavior that always happens when recording sound?

Take a look at MTStatusBarOverlay on GitHub.

Also, try this one....
Tweetbot-Like Alert Panels (Blog), and the repository is MKInfoPanelDemo at Github.

Related

Using a webview to play an mp3- is it possible to keep it playing even when the screen is locked?

I have a portion of my app that simply launches a webview linked to an mp3 file- it opens the file and plays the audio. What I'd like to do is allow that audio to continue playing even if the user locks their iPhone. (As a side note, is there any way to replace the default Quicktime logo that appears in the player? Not that big a deal, just thought I'd ask =)
A third question- I also do the same thing (webview) with an .m3u linked file to stream live audio throughout the week- is it also possible to keep it playing when the iPhone is locked?
Thanks!!
Ben
Quick Edit: The same URLs work great in IOS Safari (locking and unlocking doesn't affect the audio. Just not in my app's webviews.
I did find my answer though, in case anyone comes here looking. Easiest thing in the world too- just add a row to the plist file labeled "Required Background Modes" and under that set item 0's value to "App plays audio". Voila!
Since the audio is in a UIWebView, I don't believe that you'd be able to play it in the background.
EDIT: I was wrong, adding "App Plays Audio" to the UIBackgroundModes will make it work even when audio is in a UIWebView.
Have you thought about just streaming the .mp3 file yourself? Should be easy enough and you'd be able to setup background streaming. To get you started, I'd check out Matt Gallagher's AudioStreamer class which easily allows you to stream .mp3 files and other audio files from the net: https://github.com/mattgallagher/AudioStreamer

Responding to events when device has been locked

I'm working on a radio alarm clock, and i have some issues.
I am using local notifications for the alarms, so it has a gentle fallback if the app is not running.
I am well aware of the limitations of the device, and i know what i can and cannot do when the device has gone into background.
But my question is this:
I have seen other apps starting an audio streamer when i've locked the device. How is this possible? May this be inside an execution-timeframe?
How is the best way to implement this? Is it any way i can activate a streaming session when the device is locked?
Edit
To clarify: I know how i make audio play in the background. But the issue is triggering the audio-playback when an local notification or some other event fires.
One app that seems to do this, is Radio Alarm Clock. I haven't tried it for long period of times yet. But it seems to do this. A video demo of the app: http://www.youtube.com/watch?v=KJQiFOcdBWk
Have you already declared your background task?
Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings:
audio — The app plays audible content to the user while in the background. (This content includes streaming audio or video content using AirPlay.)
iOS App Programming Guide - Implementing Long Running Background Tasks
You can add this by clicking on your main project icon, then under the Info tab you can add "Required Background Modes" to the "Custom iOS Target Properties" section. "App Plays Audio" will be one of the three default values.
Big Edit With New Answer:
If everything else is already in order, you can keep your app running in the background using the UIApplication method
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:(void (^)(void))handler
detailed here: UIApplication Class Reference
with an example here: Hour 21: Building Background-Aware Applications
This allows you to run an instance of NSTimer which triggers your music player. The difference between this approach and UILocalNotifications is that this method never lets the app fully enter the background mode, the music player exists the entire time which subverts the need to create it from the background, which looks to be impossible.
There may be limitations to how long of a timer you can set, I haven't tested this past 14 minutes out.

view capturing in background

we can easily capture a view(screenshot) programmatically in iPhone.
But i am trying to capture screen automatically after every 5 seconds.that also, can be done.
But my main objective is , to capture screen, even if the app is closed, i.e in background.
Apple doesn't allow to background process to run for a long time, but can we do it for 5-10 min in background.
Capturing screen,even if the app is closed.Ofcourse user can close this function, within the app.
Apple might reject this, but is this possible ?
Regards
This is possible but it's not easy. You can register you app (via a .plist setting) as being a media app, this will allow it to run in the background. This is normally to allow media apps to continue playing music when the app is sent to the background. However if you are careful you can get it to do other thing in there too.
In your plist under "Required Background Modes" add a key "Item 0" and set it to "App plays Audio". This will mean you can do it.
You will then have to using AVAudioPlayer, play a silent sound that is say 5mins long, and then register one of your controllers for the AVPlayerItemDidPlayToEndTimeNotification notification. Then when this calls back, you can have your bit of code that, first takes a screenshot, and then starts the sound again.
This is the general concept, look somewhere like :
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_background-audio/
for how to set up the audio playing.
Just a note: APPLE WILL REJECT THIS!
If you are making an app for personal use only, this is fine, but will never make it to the app store.
Hoep this sheds some light on your situation! :)

iPhone UIPickerView not playing selection sound

I have a UIPickerView in my app in which the 'tick' sound when moving from one index to the next is not played. I swear it used to play the sound, but recently it has not played.
I am using custom labels for each item in the picker, and I tried commenting that out and the sound still does not play.
I have searched around and saw there is a method [pickerView setSoundsEnabled:YES], but it is a private API, so I cannot use that.
Most threads I have found are people trying to stop the sound from playing, shouldn't it be playing the sound by default?
Any help appreciated, thanks.
I believe this sound is set/unset via the system-level preferences panel, Settings->Sounds->Keyboard Clicks->On, and cannot be set at the API level (at least, not officially).
The issue ended up being with using the FMOD library. I filed a bug report, it was when using the PLAY_AND_RECORD filter.

iPhone playing sounds while in the background

I have a small application which is much like a clock. It has been working great on IOS3, but now I am updating it to iOS4.
What I want to do in iOS4 is to let it play a sound any giving time. For instance, if I set it to play at 4.00 PM I want it to play a sound, a sound from the application not from the OS. This works if the app is launced, but if the user went back to the home screen I want the same to happen.
It is OK if a UIAlertView pops up istead of the application.
How can I do this?
Best regards,
Paul Peelen
Sounds like you'll need to use a local notification:
http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html
and
http://developer.apple.com/iphone/library/documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html#//apple_ref/occ/cl/UILocalNotification
Read http://developer.apple.com/iphone/library/documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html.
What you want is UIApplication setKeepAliveTimeout:handler: which let you register a handler that will be called. You can use that to start playing audio. (Of course, compute the timeout when your app goes to background)
EDIT: Use UILocalNotification as andy said.
Two things you could possibly try under iOS 4.
Local Notifications can pop up an alert and play a short sound.
Another power hungry option is to register as a background music player, and play silence until time for the alarm to go off, then add your chosen sound to the "music" output. This will fail if the user switches to another media player app.