MumbleKit
 All Classes Functions
Instance Methods | List of all members
<MKAudioDelegate> Protocol Referenceabstract

#import <MumbleKit/MKAudio.h>

Instance Methods

(BOOL) - audioShouldBeRunning:
 

Detailed Description

MKAudioDelegate a set of optional methods that helps MKAudio in its operation.

Method Documentation

- (BOOL) audioShouldBeRunning: (MKAudio *)  audio
optional

Called when the MKAudio singleton needs to determine whether it should be running. This is needed because MKAudio abstracts away Audio Session handling on iOS.

The method should return whether or not MKAudio should be running at the time the method is called. A typical app using MumbleKit will shut down MKAudio when it is backgrounded – this must be done manually by the app.

However, Audio Session events can come in at inopportune times. For example, if Siri is acivated while in another app, and your MumbleKit-using app is backgrounded, it is possible that MKAudio's interruption callback on the AudioSession is invoked.

To properly handle such inopportune requests, MumbleKit will ask this delegate method on how to proceed.

In 'Mumble for iOS', we do the following:

  • (void) audioShouldBeRunning:audio { UIApplication *app = [[UIApplication sharedApplication] applicationState]; UIApplicationState state = [app applicationState]; switch (state) { case UIApplicationStateActive: // When in the foreground, we always keep MKAudio running. return YES; case UIApplicationStateBackground: case UIApplicationStateInactive: // When backgrounded, only turn on MKAudio if we're connected // to a server. return _connectionActive; } return NO; }

If this method is not implemented, MKAudio will fall back to a sane default, depending on OS:

For iOS, audioShouldBeRunning: returns YES if the application state is 'active'.

For Mac OS X, audioShouldBeRunning: always returns YES.

Note: This method is only used for internal decisions in MKAudio. When a MumbleKit client manually cals the start and/or stop methods of MKAudio, this method will not be consulted at all.

Parameters
audioThe MKAudio singleton instance.

The documentation for this protocol was generated from the following file: