iOS - play a song from iTunes which the user has not purchased? - ios

I have not started coding my app but I have an idea and want to see if this part of it is possible. Would it be ok if, given a track ID, I played the song (through MediaPlayer) in the app, even if the user had not bought the song and do not have it in their library?
If not, what would be the best way to play music that anyone (or most people, at least) can listen to as they use my app?

You can play music that:
is in the user's library
or, is embedded in your app
or, is available online where your app can readily access it (assuming reachability etc.)

Related

Control music of other apps within my app

I'm currenty trying to find out if it's possible to control the music of other apps, e.g. Spotify, within my app. The two solutions I found are:
using the SDK of the specific service (e.g. Spotify SDK)
take over the audio session in my app, but this only allows me to stop/ play the music
I'm trying to find a solution that provides me with pause, play, forward, backward control and access to the title, maybe also the cover. Then I came across the "Sony Headphones Connect" app. It has a page with media control buttons, the title of the current song and is does not require any kind of sing in to Spotify or something else.
Picture is from the app from the App Store, I tested the controls and they work.
So somehow it must be possible, does anyone have an idea how I can achieve my desired result or how the "Sony Headphones Connect" app is handling this issue?
I think I found the answer, the "Sony Headphones Connect" app is controlling the music over bluetooth. So it's not directly possible to control the music of another app.

Detect when user plays music when app is closed

I was wondering if there is a way the app could know if a user started to play music from the Music app or any other source (Spotify etc.). I am trying to do a specific function every time a user plays a song even if my app is not active. Is this even possible? Can I also retrieve the song information?
With AVKit you can make use:
AVAudioSession.sharedInstance().isOtherAudioPlaying
A Boolean value indicating whether another app is currently playing
audio.
Note that this will not work when your app is inactive. You canĀ“t do that and Apple will reject your app. You can only make this check if your app is active.

What is the definition of the "Apple Music API"?

I'm trying to understand the App Store Review Guidelines around the Apple Music API. However, I can't seem to find a definition for the Apple Music API, and in particular how far it extends (i.e. how much of the entire API does it encompass?).
On this iTune Affiliate Resource page it is suggested that the Apple Music API is a combination of:
SKCloudServiceController
MPMediaLibrary
MPMusicPlayerController
Is this truly the definition of the Apple Music API? And in which case, if you use any of the frameworks listed above are you technically using the Apple Music API?
To put some context, I'm planning to build a music player that utilises a device's local library only. Is there a way of building such an iOS music player app and avoid using the Apple Music API?
The point of the language you quote in your comment is merely that you must not try to do what Apple is already doing, i.e. make money by getting the user to subscribe to or access Apple Music (the online streaming service) through you rather than Apple. You aren't going to do that, so don't worry about it.
EDIT I'll give you an example of what Apple is saying you cannot do. Let's say you have an app that plays music from the user's library, and that you differentiate: you say, to play your music is free, but play Apple Music songs will cost you an extra dollar of in-app payment. That would be a violation of the rules.

Detecting which audio track is playing on device in iOS Swift

I'm creating a mood tracking app that, among other things, should use information about the songs the user listens to. Specifically, I'm interested in just extracting the titles that are otherwise visible from the locked screen view, when a track is playing. I've search the interwebs and have had no luck finding a solution to access this data using Swift.
Can anyone help?
The short answer is no.
You may be able to retrieve song information from the iTunes library (if it's not a shared song using Home Sharing). Read about MPMusicPlayerController for more information. Specially the nowPlayingItem is probably what you're looking for.
However, most third-party applications such as Spotify, Deezer or Pandora will most likely have implemented their own player, which does not integrate with the iPod music player. This blog post also covers some of the details.
It is not about your ask, but it is about theme.
I made a code to get information about track in Itunes Media, and if you need get album art or correctly track name or artist, well I think it is will help you. The code is free to use in github.
ItunesSearch

Can I save a stream-only track locally for offline capability?

I am developing an iOS app that will play music from soundcloud. I want to give the user the option of an offline mode so he/she can play music even if there is no connection available.
it is technically possible to download the streamed mp3:s locally (I have already implemented it) but will Soundcloud allow me to do it? I have no intention of making these mp3:s accessible outside the app.
The problem of using a downloaded copy instead of the streamed track would be that the play would not count. Is there a way to register a play without actually playing the track?
I have tried to reach them through mail and twitter but I have got no reply yet.
Any thoughts?
Short summary of nickf:s comment above:
this is expressly disallowed

Resources