How to get another currently playing application

How can I access another currently playing audio - actual audio element, but metadata is also welcome. I see that this question has been asked a lot, but with several solutions offered over the years. I understand Apple's philosophy, perhaps not wanting the app to do this. I also understand that such a request probably goes beyond the iOS API. With that said, I really would like some kind of solution.

Logically, I feel that

MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo 

must return information for what is currently being reproduced; however, as others have noted, this value is always nil for playing audio outside of your application. It is noteworthy that popular audio applications did not seem to be able to use the MPNowPlayingInfoCenter class to prevent such sound from being displayed.

When using the default music application, you can use

 MPMusicPlayerController.systemMusicPlayer().nowPlayingItem 

However, what is a more consistent way to access audio games through the podcast app, Spotify, Pandora, Safari, etc.?

Has anyone found a solution? Are there old Objective-C frameworks that support this functionality?

One approach may be viable if there is some way to access the audio track of the current item. For example, if I could get the path to the currently playing item, I could create an AV object from it:

 AVAudioPlayer(contentsOfURL: audioUrl) 

So, is there a way to get the audio URL of the current playable item and use it that way?

Is the other approach improved?

If a native solution does not exist, is it possible to combine something for its work? Any tips or ideas are welcome.

Edit: I do not believe that anyone was able to achieve this; however, I think many people would like to. If this has been fixed, please connect it! :)

+3
source share
1 answer

This is currently not possible on iOS. Just changing the parameters of the AVAudioSession category to. MixWithOthers , which will be able to receive song information from other applications, ignores your nowPlayingInfo .

iOS considers non-mixing applications to be included in MPNowPlayingInfoCenter , because there is uncertainty as to which application will be displayed in (for example) the Control Center if there are several mixing applications at the same time.

Suggestion: The option is to use an automatic fingerprint algorithm to recognize what is being played by recording it from your application.

Some interesting projects in this direction:

Gracenote https://developer.gracenote.com/ Gracenote (owned by Sony) has opened its SDK and API and has a proper developer portal.

EchoNest and Spotify API http://developer.echonest.com/ Merge with Spotify since March 2016

ACRCloud https://www.acrcloud.com/ offers ACR solutions for custom files such as commercials, tec music

+1
source

Source: https://habr.com/ru/post/1241793/


All Articles