Get current song playing in Spotify on iPhone
The Apple Documentation states there are two types of music player:
- An application music player plays music locally within your app. It is not aware of the Music app’s now-playing item, nor does it
affect the Music app’s state. There are two application music players:
applicationMusicPlayer
andapplicationQueuePlayer
. The application
queue player provides greater control over the contents of the queue
and is the preferred player.- The system music player employs the built-in Music app on your behalf. On instantiation, it takes on the current Music app state,
such as the identification of the now-playing item. If a user switches
away from your app while music is playing, that music continues to
play. The Music app then has your music player’s most recently-set
repeat mode, shuffle mode, playback state, and now-playing item.
The first is only within your app and the second is the Apple Music app, since you can't reach out of your app's sandbox in a normal app this is not possible in App Store apps.
If however you still want to create your idea you can develop this on a jailbroken device. This github project has an easy example of how to get the current playing song in a jailbreak tweak. If you want to try it, this is an excellent, be it a bit old, still accurate tutorial on how to get started developing tweaks.
Update
I just ran into this Spotify SDK that will let users login and play the users Spotify music. This way the music stream will be inside your app and you have access to all info in the applicationMusicPlayer. The downside is that this will be a lot more work to set up than just getting the information about Spotify's playing track and the user will have to play his music from your app instead of the Spotify app.
Apple Music API Get Currently Playing Song
Unfortunately their API is pretty lame. If you not play anything at the moment you still got a song that was played recently even if that recently was a day ago. Even worse there is no unixdate attached result so you don't know when the song was last accessed.
Related Topics
3D Touch Quick Actions Not Working at All
Split String into Array of Arrays
Manage a Uipickerview from an External Class - Using Swift
What Are the First Two Columns in Scnmatrix4
Simplest Way to Implement a "Read More" Button to Expand a Uitextview in iOS Swift 2
How to Add a Link for a Rate Button with Swift
Swift: Bring View from Stack View to Front
Avplayer Not Full Screen in Landscape Mode Using iOS Swift
Swift 1.2 and Parse: Issue with Retrieving Images to Populate Pfquerycollectionviewcontroller
7 Duplicate Symbols for Architecture X86_64 in React Native
How to Change the Font Size of a Uilabel in Swift
Save Depth Images from Truedepth Camera
How to Set Clear Background in Table View Cell Swipe Action
Cannot Set Color of Button's Label Inside Menu in Swiftui
Make a Uiwebview as Height as Its Content with Auto Layout