Intercept background audio stream on iOS - ios

Is it possible for an iOS app to intercept the background audio stream that's playing?
I'd like to do some visualization for whatever audio is currently playing whether it's iTunes, Spotify, etc.

You can't get access to this, actually.
It's possible to play music with an app that remains in the background when the app isn't active, but you can't get access to another app's audio stream.

Apparently this is possible now, only if another app subscribes to InterApp Audio or Audiobus.
Consolidated from other SO answers for clarity:
Is there a way to intercept audio output from within your app to display back an audio visualizer on iOS?
Intercept/modify audio stream on iOS

Related

Possible to access/monitor tvOS system audio output?

I'd like to develop a music visualizer app for tvOS which has the ability to listen to whatever background audio is playing (like Spotify, Pandora, etc.). Does anyone know if this is even possible on iOS/tvOS? In other words, there would have to be some functionality that allows the system audio output to be treated like an audio input.
I imagine that it would be the same functionality as doing a screen recording capture, at least the audio part.
My goal is to be able to do this programatically (Objective-C) so that the user doesn't have to do anything, it just "works" out of the box, so to speak.
Thanks

How to add a music background in the video chat on iOS?

I have a question about the AVAudioPlayer and its AVAudioSessionCategory parameter.
So, basically, I have a video chat between two users and I want to play music as a background for them. I tried to use the "AVAudioSessionCategoryPlayAndRecord" value for the AVAudioSessionCategory, but in that case, the music will be recorded and send together with the voice to the partner.
I think that I'm looking for a way to play music but do not record it, so each partner will be listening to its own music.

How to resume audio playback of other apps after deactiving the audio session and how to start audio playback in the background without mixing?

I am building a iOS app with Ionic and Capacitor. I use AVFoundation inside a Capacitor plugin which provides a public method to play an audio file accessible at a remote URL. The basics work, the audio file is successfully played. Now I want to correctly handle interruptions and background audio. By background audio I mean start playing an audio file while the app is in the background and not continue playing it in the background when it was started in foreground before. To summarize, the app should behave the following way:
If another app (e.g. Spotify) is playing audio and my app wants to play audio, the other app should be interrupted and my app's audio should start playing without mixing.
If my app's audio is finished playing, the other app's audio should resume.
My app must be able to start playing audio without mixing when it is in the background.
I want to show a play/pause button and the audio title on the lockscreen and in the notification center.
I added the background mode audio capability. I use AVPlayer, AVAudioSession, MPNowPlayingInfoCenter and MPRemoteCommandCenter, followed best practices, especially regarding activation and deactivation of an audio session and interruption handling. I followed this question and this question. I tried several solutions, but never managed to achieve all of the above goals. What I found out so far is the following:
Goal 1. above is easy to achieve. Simply activate an audio session without mixing and start playing the audio.
After the audio of my app is finished, I deactivate the audio session. Unfortunately, I can only achieve goal 2. above if I don't use remote commands nor notification info. This means, my app then has no audio control UI on the lockscreen nor in the notification center. Somehow the configurations of MPNowPlayingInfoCenter and MPRemoteCommandCenter seem to affect the interruption behavior. As far as I could see, Apple documentation doesn't say anything about this.
I only manage to start playing audio in the background when setting the option .mixWithOthers. Apple documentation doesn't say anything about this, either.
Any help would be greatly appreciated.
Rony

How to receive short audio clips over bluetooth from an external device and play it from an iPhone?

Is it possible to receive short audio clips from an external device over Bluetooth and then play it from the iPhone?
I don't want to store multiple audio clips in the local database as I want my app to be more light.
Thanks in advance.

How to continue playing a youtube video at background when switch from my app back to home screen

Seems the default action for iOS 6 is to stop the video from playing after I switch to HOME screen. Then if I want to listen to the audio I have to go back to the app and press the 'Play' button again. I am using youtube API.
How can I continue playing the video when the application is in UIApplicationStateInactive and UIApplicationStateBackground. I just want to be able to listen to the audio even if I am on HOME screen or the screen is locked. Should I use a background thread or restart playing the video at the previous position as it was before turning the app inactive?
Take a look at the app 'Jasmine'. They managed to do something similar to what you are seeking. However, UIApplicationStateInactive/UIApplicationStateBackground will cause the video to pause. Double tapping the home button and then pressing the audio play button will cause the video's audio to resume without keeping the app active.
Take a look at the new iOS 7. You may have some luck there.
Inter-App Audio
Now your apps can make beautiful music together. With Inter-App Audio,
apps can register their audio streams to share with other apps. For
example, a series of apps could publish audio streams of instrument
tracks while another uses the combination of these streams to compose
a song. Inter-App Audio also provides for MIDI control of audio
rendering, remotely launching other registered Inter-App Audio apps
and more.

Resources