OpenEars listening while app is in background

Home Forums OpenEars OpenEars listening while app is in background

Viewing 18 posts - 1 through 18 (of 18 total)

  • Author
    Posts
  • #8572
    jdkaire
    Participant

    First of all I have to say that OpenEars works amazing. Just by following the tutorial you are able to include it in your app easily and it just works.

    I just have one question…Is there a way to have OpenEars still listening while the app is on the background? I mean, when the user switches to another app or presses the home button but doesn’t close mine…

    Thanks a lot!

    Joe

    #8573
    Halle Winkler
    Politepix

    Welcome,

    Nope, sorry, this isn’t possible. I haven’t pursued it because I don’t think it’s background behavior that Apple intends to accept. Thanks for being straightforward about it though, since it’s frustrating when people ask for this feature under the guise of asking for a different feature.

    #8574
    jdkaire
    Participant

    Halle, thanks for your fast response. I have searched everywhere and couldn’t find the answer. So, that’s why I decided to get directly to the point and ask you. At least now I know for sure.

    Thanks again,

    Joe

    #9062
    hartsteins
    Participant

    Actually…..this IS possible. It depends on what sort of background app you may already have running. It is not possible to keep OpenEars going all on its own, but if your app is one of the 3 apple background apps (voip, audio, or location) then OpenEars will continue as active and listening.

    #9064
    Halle Winkler
    Politepix

    Weird, the last time I tested it as audio type background app it didn’t work. It’s been a few versions though, I can believe it’s changed.

    #9067
    hartsteins
    Participant

    I am using OpenEars version 0.913 on iOS 5.0 and it seems to work. I did make some changes to the AudioSessionManager however that might be making this possible specifically kAudioSessionProperty_OverrideCategoryMixWithOthers.

    When it goes to background, iOS shows “fancy” red navigation bar as OpenEars keeps recording. I am using for continued iPod control, but an easy test is to fire local notifications on specific word/phrase recognition.

    Greg

    #9071
    Halle Winkler
    Politepix

    That’s excellent.

    #9193
    jdkaire
    Participant

    Yes, my app is not one of the 3 types that Apple lets run in the background, but I found a way to make the app useful.

    thanks guys

    #9448
    gotok
    Participant

    I have a GPS/TTS (Flite) app that I would like to get working in the background. The app uses Flite to speak GPS values like speed. If I set the “Required background modes” to “App registers for location updates” (i.e. one of the three cases for background operation) then the GPS part of my app continues to work in the background, but Flite does not. Is there any way to get Flite to work in the background?

    #9540
    hartsteins
    Participant

    gotok,

    Register app in required background modes as “App plays audio” as well

    Greg

    #9541
    gotok
    Participant

    @hartsteins,
    Thanks for the reply. I’ve tried that and it seems only one or the other works for my app. If I set GPS as the first item in the array and audio as the second, then GPS will work with the screen locked, but not Flite. However, if audio is in the first position of the array, then Flite works but not GPS. In the GPS method “didUpdateToLocation”, which runs when there is a GPS location update, I compute max speed and also when speed exceeds various thresholds, I use Flite to speak the speed. I can tell if GPS runs under screen lock if top speed gets computed. With GPS first in the array, I get max speed computed with the screen locked, but no Flite speaking. I can also test Flite by pressing a button. When I do this to start Flite speaking, then press the screen lock, if audio is set first in the array, the speaking will continue after the screen is locked. However, if GPS is first in the array, then the speaking will cut off when the screen is locked and continue when unlocked. Any idea why the GPS and audio cases seem to be mutually exclusive for my app?

    #9542
    gotok
    Participant

    @hartsteins,
    Just for fun, I did another test with VOIP at the 3rd position in the array even though it doesn’t apply for my app. I this case, the GPS method runs, but the Flite speech initiated from it does not. However, Flite speech initiated from a button continues even after the screen is locked. I wish that I could find out exactly what happens when the various background modes (audio, location, voip) are set. Do you know of any documentation on this?
    Thanks for your help..

    #9588
    gotok
    Participant

    UPDATE:
    After more reading in the IOS Library, I set the audio category for my app to “AVAudioSessionCategoryPlayback” and also set the override switch to allow mixing with other applications. The background modes for both audio and location are set in my plist. Now my app works in background mode and will even continue to work when music is playing in the background as well. So, Flite will indeed run in background mode.

    #9589
    Halle Winkler
    Politepix

    Very cool, thanks for describing this in detail.

    #1015529
    ilyashev
    Participant

    Just to add one, perhaps obvious, point. In order to continue operating the app in the background, and play *multiple* strings via openears, I had to wrap the actions in a background task. I.e.:

    – (void) performBGTask
    {
    UIApplication *application = [UIApplication sharedApplication];

    bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
    NSLog(@”background operation expiration handler”);
    [application endBackgroundTask:bgTask];
    bgTask = UIBackgroundTaskInvalid;
    }];

    [self performSelector:@selector(speakNextPhrase) withObject:nil afterDelay:.25];
    // Start the long-running task
    }

    Otherwise, even with all the audio settings adjusted as suggested above, once the screen was locked the next phrase would not play once the already playing audio ceased.

    #1018195
    pooja
    Participant

    Hi
    I want the OpenEars to be active and listening in background even if screen is locked or some other application is in foreground.How can this be achieved.

    #1018855
    Anonymous
    Inactive

    As long as the app is registered as a valid background app, and remains active, listening works in foreground, background, and even when the screen is locked.

    Staying active is the key thing here.

    #1020871
    flanagan.james
    Participant

    I can confirm that my app using OpenEars and Flite continues to work in background when registered in Xcode “Capabilities” as having an “audio and Airplay” background mode. The app as well as my thanks for the excellent OpenEars tools and even better explanation of how to use then are found here: http://flanaganjames.wordpress.com. As someone said above “it just works”.

Viewing 18 posts - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.