Class AVAudioSession

  • All Implemented Interfaces:
    NSObject

    public class AVAudioSession
    extends NSObject
    • Constructor Detail

      • AVAudioSession

        protected AVAudioSession​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

        public static java.lang.Object allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(java.lang.Object aTarget,
                                                                                 org.moe.natj.objc.SEL aSelector,
                                                                                 java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        public static org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(java.lang.String key)
      • new_objc

        public static java.lang.Object new_objc()
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • sharedInstance

        public static AVAudioSession sharedInstance()
        Return singleton instance.
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • version_static

        public static long version_static()
      • IOBufferDuration

        public double IOBufferDuration()
        The current hardware IO buffer duration in seconds.
      • availableCategories

        public NSArray<java.lang.String> availableCategories()
        Get the list of categories available on the device. Certain categories may be unavailable on particular devices. For example, AVAudioSessionCategoryRecord will not be available on devices that have no support for audio input.
      • availableInputs

        public NSArray<? extends AVAudioSessionPortDescription> availableInputs()
        Get the set of input ports that are available for routing. Note that this property only applies to the session's current category and mode. For example, if the session's current category is AVAudioSessionCategoryPlayback, there will be no available inputs.
      • availableModes

        public NSArray<java.lang.String> availableModes()
        Get the list of modes available on the device. Certain modes may be unavailable on particular devices. For example, AVAudioSessionModeVideoRecording will not be available on devices that have no support for recording video.
      • category

        public java.lang.String category()
        Get session category. Examples: AVAudioSessionCategoryRecord, AVAudioSessionCategoryPlayAndRecord, etc.
      • categoryOptions

        public long categoryOptions()
        Get the current set of AVAudioSessionCategoryOptions.
      • currentHardwareInputNumberOfChannels

        @Deprecated
        public long currentHardwareInputNumberOfChannels()
        Deprecated.
      • currentHardwareOutputNumberOfChannels

        @Deprecated
        public long currentHardwareOutputNumberOfChannels()
        Deprecated.
      • currentHardwareSampleRate

        @Deprecated
        public double currentHardwareSampleRate()
        Deprecated.
        deprecated. Use the corresponding properties without "Hardware" in their names.
      • currentRoute

        public AVAudioSessionRouteDescription currentRoute()
        A description of the current route, consisting of zero or more input ports and zero or more output ports
      • init

        public AVAudioSession init()
        AVAudioSession is a singleton. Use +sharedInstance instead of -init
        Overrides:
        init in class NSObject
      • inputDataSource

        public AVAudioSessionDataSourceDescription inputDataSource()
        Obtain the currently selected input data source. Will be nil if no data sources are available.
      • inputDataSources

        public NSArray<? extends AVAudioSessionDataSourceDescription> inputDataSources()
        DataSource methods are for use with routes that support input or output data source selection. If the attached accessory supports data source selection, the data source properties/methods provide for discovery and selection of input and/or output data sources. Note that the properties and methods for data source selection below are equivalent to the properties and methods on AVAudioSessionPortDescription. The methods below only apply to the currently routed ports. Key-value observable.
      • inputGain

        public float inputGain()
        value in range [0.0, 1.0]
      • inputIsAvailable

        @Deprecated
        public boolean inputIsAvailable()
        Deprecated.
        is input hardware available or not?
      • inputLatency

        public double inputLatency()
        The current hardware input latency in seconds.
      • inputNumberOfChannels

        public long inputNumberOfChannels()
        The current number of hardware input channels. Is key-value observable.
      • isInputAvailable

        public boolean isInputAvailable()
        True if input hardware is available.
      • isInputGainSettable

        public boolean isInputGainSettable()
        True when audio input gain is available. Some input ports may not provide the ability to set the input gain, so check this value before attempting to set input gain.
      • isOtherAudioPlaying

        public boolean isOtherAudioPlaying()
        True when another application is playing audio. Note: As of iOS 8.0, Apple recommends that most applications use secondaryAudioShouldBeSilencedHint instead of this property. The otherAudioPlaying property will be true if any other audio (including audio from an app using AVAudioSessionCategoryAmbient) is playing, whereas the secondaryAudioShouldBeSilencedHint property is more restrictive in its consideration of whether primary audio from another application is playing.
      • maximumInputNumberOfChannels

        public long maximumInputNumberOfChannels()
        Returns the largest number of audio input channels available for the current route
      • maximumOutputNumberOfChannels

        public long maximumOutputNumberOfChannels()
        Returns the largest number of audio output channels available for the current route
      • mode

        public java.lang.String mode()
        Get the session's mode.
      • outputDataSource

        public AVAudioSessionDataSourceDescription outputDataSource()
        Obtain the currently selected output data source. Will be nil if no data sources are available.
      • outputLatency

        public double outputLatency()
        The current hardware output latency in seconds.
      • outputNumberOfChannels

        public long outputNumberOfChannels()
        The current number of hardware output channels. Is key-value observable.
      • outputVolume

        public float outputVolume()
        The current output volume. Value in range [0.0, 1.0]. Is key-value observable.
      • overrideOutputAudioPortError

        public boolean overrideOutputAudioPortError​(long portOverride,
                                                    org.moe.natj.general.ptr.Ptr<NSError> outError)
        Use this method to temporarily override the output to built-in speaker. This method is only valid for a session using PlayAndRecord category. This change remains in effect only until the current route changes or you call this method again with the AVAudioSessionPortOverrideNone option. Sessions using PlayAndRecord category that always want to prefer the built-in speaker output over the receiver, should use AVAudioSessionCategoryOptionDefaultToSpeaker instead.
      • preferredHardwareSampleRate

        @Deprecated
        public double preferredHardwareSampleRate()
        Deprecated.
      • preferredIOBufferDuration

        public double preferredIOBufferDuration()
      • preferredInput

        public AVAudioSessionPortDescription preferredInput()
        Get the preferred input port. Will be nil if no preference has been set.
      • preferredInputNumberOfChannels

        public long preferredInputNumberOfChannels()
      • preferredOutputNumberOfChannels

        public long preferredOutputNumberOfChannels()
      • preferredSampleRate

        public double preferredSampleRate()
      • recordPermission

        public long recordPermission()
        Returns an enum indicating whether the user has granted or denied permission to record, or has not been asked
      • requestRecordPermission

        public void requestRecordPermission​(AVAudioSession.Block_requestRecordPermission response)
        Checks to see if calling process has permission to record audio. The 'response' block will be called immediately if permission has already been granted or denied. Otherwise, it presents a dialog to notify the user and allow them to choose, and calls the block once the UI has been dismissed. 'granted' indicates whether permission has been granted. Note that the block may be called in a different thread context.
      • sampleRate

        public double sampleRate()
        The current hardware sample rate
      • secondaryAudioShouldBeSilencedHint

        public boolean secondaryAudioShouldBeSilencedHint()
        True when another application with a non-mixable audio session is playing audio. Applications may use this property as a hint to silence audio that is secondary to the functionality of the application. For example, a game app using AVAudioSessionCategoryAmbient may use this property to decide to mute its soundtrack while leaving its sound effects unmuted. Note: This property is closely related to AVAudioSessionSilenceSecondaryAudioHintNotification.
      • setActiveError

        public boolean setActiveError​(boolean active,
                                      org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set the session active or inactive. Note that activating an audio session is a synchronous (blocking) operation. Therefore, we recommend that applications not activate their session from a thread where a long blocking operation will be problematic. When deactivating a session, the caller is required to first stop or pause all running I/Os (e.g. audio queues, players, recorders, converters, remote I/Os, etc.). Starting in iOS 8, if the session has running I/Os at the time that deactivation is requested, the session will be deactivated, but the method will return NO and populate the NSError with the code property set to AVAudioSessionErrorCodeIsBusy to indicate the misuse of the API. Prior to iOS 8, the session would have remained active if it had running I/Os at the time of the deactivation request.
      • setActiveWithFlagsError

        @Deprecated
        public boolean setActiveWithFlagsError​(boolean active,
                                               long flags,
                                               org.moe.natj.general.ptr.Ptr<NSError> outError)
        Deprecated.
      • setActiveWithOptionsError

        public boolean setActiveWithOptionsError​(boolean active,
                                                 long options,
                                                 org.moe.natj.general.ptr.Ptr<NSError> outError)
      • setAggregatedIOPreferenceError

        public boolean setAggregatedIOPreferenceError​(long inIOType,
                                                      org.moe.natj.general.ptr.Ptr<NSError> outError)
        Controls whether audio input and output are aggregated. Only valid in combination with AVAudioSessionCategoryPlayAndRecord or AVAudioSessionCategoryMultiRoute. See the AVAudioSessionIOType documentation for a more detailed explanation of why a client may want to change the IO type.
      • setCategoryError

        public boolean setCategoryError​(java.lang.String category,
                                        org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set session category.
      • setCategoryModeOptionsError

        public boolean setCategoryModeOptionsError​(java.lang.String category,
                                                   java.lang.String mode,
                                                   long options,
                                                   org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set session category and mode with options.
      • setCategoryWithOptionsError

        public boolean setCategoryWithOptionsError​(java.lang.String category,
                                                   long options,
                                                   org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set session category with options.
      • setDelegate_unsafe

        @Deprecated
        public void setDelegate_unsafe​(AVAudioSessionDelegate value)
        Deprecated.
      • setInputDataSourceError

        public boolean setInputDataSourceError​(AVAudioSessionDataSourceDescription dataSource,
                                               org.moe.natj.general.ptr.Ptr<NSError> outError)
        Select a new input data source. Setting a nil value will clear the data source preference.
      • setInputGainError

        public boolean setInputGainError​(float gain,
                                         org.moe.natj.general.ptr.Ptr<NSError> outError)
        A value defined over the range [0.0, 1.0], with 0.0 corresponding to the lowest analog gain setting and 1.0 corresponding to the highest analog gain setting. Attempting to set values outside of the defined range will result in the value being "clamped" to a valid input. This is a global input gain setting that applies to the current input source for the entire system. When no applications are using the input gain control, the system will restore the default input gain setting for the input source. Note that some audio accessories, such as USB devices, may not have a default value. This property is only valid if inputGainSettable is true. Note: inputGain is key-value observable.
      • setModeError

        public boolean setModeError​(java.lang.String mode,
                                    org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set the session's mode. Modes modify the audio category in order to introduce behavior that is tailored to the specific use of audio within an application. Examples: AVAudioSessionModeVideoRecording, AVAudioSessionModeVoiceChat, AVAudioSessionModeMeasurement, etc.
      • setOutputDataSourceError

        public boolean setOutputDataSourceError​(AVAudioSessionDataSourceDescription dataSource,
                                                org.moe.natj.general.ptr.Ptr<NSError> outError)
        Select a new output data source. Setting a nil value will clear the data source preference.
      • setPreferredHardwareSampleRateError

        @Deprecated
        public boolean setPreferredHardwareSampleRateError​(double sampleRate,
                                                           org.moe.natj.general.ptr.Ptr<NSError> outError)
        Deprecated.
      • setPreferredIOBufferDurationError

        public boolean setPreferredIOBufferDurationError​(double duration,
                                                         org.moe.natj.general.ptr.Ptr<NSError> outError)
        The preferred hardware IO buffer duration in seconds. The actual IO buffer duration may be different.
      • setPreferredInputError

        public boolean setPreferredInputError​(AVAudioSessionPortDescription inPort,
                                              org.moe.natj.general.ptr.Ptr<NSError> outError)
        Select a preferred input port for audio routing. If the input port is already part of the current audio route, this will have no effect. Otherwise, selecting an input port for routing will initiate a route change to use the preferred input port. Setting a nil value will clear the preference.
      • setPreferredInputNumberOfChannelsError

        public boolean setPreferredInputNumberOfChannelsError​(long count,
                                                              org.moe.natj.general.ptr.Ptr<NSError> outError)
        Sets the number of input channels that the app would prefer for the current route
      • setPreferredOutputNumberOfChannelsError

        public boolean setPreferredOutputNumberOfChannelsError​(long count,
                                                               org.moe.natj.general.ptr.Ptr<NSError> outError)
        Sets the number of output channels that the app would prefer for the current route
      • setPreferredSampleRateError

        public boolean setPreferredSampleRateError​(double sampleRate,
                                                   org.moe.natj.general.ptr.Ptr<NSError> outError)
        The preferred hardware sample rate for the session. The actual sample rate may be different.
      • routeSharingPolicy

        public long routeSharingPolicy()
        Get the route sharing policy. See AVAudioSessionRouteSharingPolicy for a description of the available policies. See setCategory:mode:routeSharingPolicy:options:error: for additional discussion.
      • setCategoryModeRouteSharingPolicyOptionsError

        public boolean setCategoryModeRouteSharingPolicyOptionsError​(java.lang.String category,
                                                                     java.lang.String mode,
                                                                     long policy,
                                                                     long options,
                                                                     org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set session category, mode, routing sharing policy, and options. Use of the long-form route sharing policy is only valid in conjunction with a limited set of category, mode, and option values. Allowed categories: AVAudioSessionCategoryPlayback. Allowed modes: AVAudioSessionModeDefault, AVAudioSessionModeMoviePlayback, AVAudioSessionModeSpokenAudio. Allowed options: None. Options are allowed when changing the routing policy back to Default, however.
      • allowHapticsAndSystemSoundsDuringRecording

        public boolean allowHapticsAndSystemSoundsDuringRecording()
        Whether system sounds and haptics can play while the session is actively using audio input.
      • promptStyle

        public long promptStyle()
        The prompt style is a hint to sessions using AVAudioSessionModeVoicePrompt to alter the type of prompts they issue in response to other audio activity on the system, such as Siri and phone calls. This property is key-value observable.
      • setAllowHapticsAndSystemSoundsDuringRecordingError

        public boolean setAllowHapticsAndSystemSoundsDuringRecordingError​(boolean inValue,
                                                                          org.moe.natj.general.ptr.Ptr<NSError> outError)
        Set allowHapticsAndSystemSoundsDuringRecording to YES in order to allow system sounds and haptics to play while the session is actively using audio input. Default value is NO.
      • prepareRouteSelectionForPlaybackWithCompletionHandler

        public void prepareRouteSelectionForPlaybackWithCompletionHandler​(AVAudioSession.Block_prepareRouteSelectionForPlaybackWithCompletionHandler completionHandler)
        prepareRouteSelectionForPlaybackWithCompletionHandler: A call to this method is an indication that playback is about to start. This gives the receiver an opportunity to prompt the user to pick an output destination if necessary. The receiver will only prompt if the audio session has been configured with a long-form video route sharing policy. Presenting playback UI (e.g. AVPlayerViewController) and commencing playback should be performed in the completionHandler.
        Parameters:
        completionHandler - Once any potential routing is complete, the completion handler is called with the selected route type and with a BOOL indicating whether playback should begin or not.
      • inputOrientation

        public long inputOrientation()
        Describes the orientation of the input data source (valid for the built-in mic input data source when a stereo polar pattern is selected).
      • preferredInputOrientation

        public long preferredInputOrientation()
      • setPreferredInputOrientationError

        public boolean setPreferredInputOrientationError​(long orientation,
                                                         org.moe.natj.general.ptr.Ptr<NSError> outError)
        Sets the preferred input orientation. The input orientation determines which directions will be left and right when a built-in mic data source with the AVAudioSessionPolarPatternStereo polar pattern is selected. Typically, this orientation should match how the user is holding the device while recording, which will match the application's interface orientation when a single app is on the screen. The actual input orientation may be different, for example, if another app's session is in control of routing. The input orientation is independent of the orientation property of an AVAudioSessionDataSourceDescription.