Hi, my team is developing an iOS app which connects to Apple Music (currently most of it is via API, but some tests have been done with MusicKit). In a separate development, we were using a service which competes with A.M., and when their (web) API is used, if the user doesn't interact with the app somehow (scrolling, buttons, etc), the connection will timeout after 30 seconds and force them to reconnect.
So, questions I have are:
Is there any timeout regarding stopping tracks in Apple Music or does the connection to the A.M. app stay active?
If the connection drops on iOS as well, is there any limitation regarding streaming A.M. content via API (aka are there licensing issues as well?)
MusicKit
RSS for tagLet users play Apple Music and their local music library from your app using MusicKit.
Posts under MusicKit tag
139 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I am working on an app to play music from the users' library on macOS.
I'm not using catalyst btw.
Whenever I try to play the track from an album I run into an issue where the track play out of order.
I set the queue like this:
musicPlayer.queue = ApplicationMusicPlayer.Queue(album: album, startingAt: tracks[index])
Where album is an Album instance that was retrieved through a library request MusicLibraryRequest<MusicKit.Album>
And musicPlayer is a reference to ApplicationMusicPlayer.shared
When I print out the entries variable the tracks are in the correct order.
(I'm using Xcode 15.1 and macOS 14.2)
Am I doing something obviously wrong? Or is this a known issue?
Thanks in advance,
Daan
Hi,
In iOS 17.0 Apple introduced a favorite button for the music app. This favorite button is available everywhere including Control Center and CarPlay.
My question is if there is a way to show/use this favorite button in my own app. Couldn't find it in the documentation.
Thank you..!
Greetings Fellow Humans,
My player uses the v3 musickit-js library. I am trying to handle situations where a user tries to play explicit content in my player with an account that has content restrictions enabled. I don't see a mechanism to know if the toggle is set in the account. The only mechanism I see is to respond to a CONTENT_RESTRICTED error as handled by the callback to the function I provide as a callback to the mediaPlaybackError event.
I have attached many callbacks (like bufferedProgressDidChange) and those all work, but this one never fires.
music.addEventListener("mediaPlaybackError", onPlaybackError);
Or
music.addEventListener(MusicKit.Events.mediaPlaybackError, onPlaybackError);
My onPlaybackError function, at least for debugging purposes, is:
function onPlaybackError(e) {
console.log("onPlaybackError");
console.log(e);
}
There are so many error conditions that are meant to be handled in this way but the callback never happens. Am I missing something? Why doesn't this callback fire?
Thanks!
Trying to use the Apple Music API for mirroring playlists from spotify. Wondering if it will ever be on the roadmap to update/reorder playlists, or delete playlists/remove items using the API?
Is this something that can't be handled or is it a business decision? I see that there is more flexibility with the MusicKit. Can we expect something like this in the future for the API?
Thanks,
is it possible to use MusicKit to fetch us apple music/iTunes analytics of a user like the number of plays per song like a lot exist for Spotify. If so can someone please guide me as I need it for a project. Thanks!
Since the latest updates of macOS, probably 14.1, I have not been able to play media using SystemMusicPlayer.shared or MPMusicPlayerController.systemMusicPlayer. ApplicationMusicPlayer still works.
This is the error code I am encountering:
systemMusicPlayer _establishConnectionIfNeeded failed [application failed to launch]
Failed to prepareToPlay with error: Error Domain=MPMusicPlayerControllerErrorDomain Code=10 "Failed to obtain remoteObject [nil server]" UserInfo={NSDebugDescription=Failed to obtain remoteObject [nil server]}
Here is a small example to reproduce the bug.
MPMusicPlayerController.systemMusicPlayer.setQueue(with: ["1445887715"])
MPMusicPlayerController.systemMusicPlayer.prepareToPlay()
Or:
extension PlayableMusicItem {
// Not working
func playWithSystemPlayer() {
Task {
SystemMusicPlayer.shared.queue = [self]
try await SystemMusicPlayer.shared.play()
}
}
// Working
func playWithApplicationPlayer() {
Task {
ApplicationMusicPlayer.shared.queue = [self]
try await ApplicationMusicPlayer.shared.play()
}
}
}
Overview
Hi I'm an Android Engineer at Mapbox. We are building SDKs that would include Apple Music integrations. The issue is that we cannot publish an .aar file that includes .aar files.
Direct local .aar file dependencies are not supported when building an AAR
So the question is, why isn't Apple Music Android SDK published to maven? It's bizarre to download android sdks and then include raw versions in your app anyways. To be specific, the issue is talking about these files.
mediaplayback-release-1.1.1.aar
musickitauth-release-1.1.2.aar
If the artifacts were uploaded to maven, then we could make them part of a build.gradle like this:
implementation("com.apple.music.mediaplayback:1.1.1")
implementation("com.apple.music.musickitauth:1.1.2")
Questions
Has someone published these SDKs so we can include them without a raw download?
Is there a legal reason to not publish it ourselves?
I just ripped a CD onto my Itunes, and when it plays on the CD, it plays gapless as intended, but when ripped and uploaded to my Itunes and Iphone, there is a gap. I hate it. I know previously you could have gapless playback. Can you PLEASE bring it back? It is a simple fix, update your software, and bring back gapless playback please. People have complained about it before, DO something about it.
Hello,
I want to fetch all local music files from an iPhone device. I tried MPMediaQuery but I can get only that file which is in the document folder.If we use UIDocumentpicker we can fetch all files from the iPhone (downloads, File Application)after selection by the user.
I want to fetch all music files like UIDocumentpicker but without user interaction. Thanks in Advance for your guidance.
I'm using iCloud Music Library. I’m using macOS 14.1 (23B74) and iOS 17.1.
i’m using MusicKit to find songs that do not have artwork. On iOS, Song.artwork will be nil for items I know do not have artwork. On macOS, Song.artwork is not nil. However when the songs are shown in Music.app, they do not have Artwork. Is this expected? Alternately, is there a more correct way to determine that a Song has no Artwork?
I have also filed FB13315721.
Thank you for any tips!
I've tried to play the same song on mac and iOS, in Mac the play count seem to update when I tap "info" of the song. But when I try to access it on iOS, even after playing the song on the same iOS device, the count and play date is always nil.
I've checked my MusicKit which = authorized.
Let me know if this is some thing iOS doesn't support
Is it possible to get timestamp in any of the API endpoints present in applemusic API
Here's the documentation -> https://developer.apple.com/documentation/applemusicapi/
Hello, I have a music player application that uses MPMusicPlayerController to play Apple Music songs. Now I want to add a Widget to it that can trigger playback pause on iOS 17. How do I need to achieve this? I can get the playbackStoreID of the song on the Widget Extension and use MPMusicPlayerController setQueue(with:) to play it. How do I pass the playbackStoreID in the Widget to the main application for playback, or should I create a new MPMusicPlayerController on the Widget Extension for playback?
Apple Music Kit API will throw an Unauthorized 403 error when I log in successfully using an Apple Music account that has no Apple Music Subscription.
After I successfully log in with my credentials, I will see a "Play full songs on the web" screen that indicates a successful log in. When I click "try it now" or "not now," the API will throw a "AUTHORIZATION_ERROR: Unauthorized."
Authorization status will be set to 0, preview only will be set to false.
Shouldn't the authorization be a success after the user has logged in? Ideally, the status should be a 1and preview true.
I think what is missing is the consent screen which shows up only when the user is a subscribed member.
When using MusicKit to get a playlist MusicLibraryRequest<Playlist>() with includeOnlyDownloadedContent and then getting the selected playlist's entries via playlist.with([.entries], preferredSource: .library), the entries include all of the items in the playlist, not the downloaded items.
Does this mean I need to make another MusicLibraryRequest call (or set of calls, for large playlists) to get only the downloaded tracks in the playlist instead of loading the entries via .with(...)?
I've been using Apple Music for months, but the problem is that there's a major bug in the "play next" button when i bring a track to the top from the Queue.
Kindly resolve the issue.
Could someone please tell me what will I get if the bug that I filed is True?
Bug Number: FB13199731.
Thanks and Regards,
Siddharth Ahuja.
Hi there,
It seems I'm getting crashes in the Apple Music subscription view sometimes. Couldn't figure out why.
crash_info_entry_0 _MusicKit_SwiftUI/MusicSubscriptionOffer.swift:73: Fatal error: Unexpectedly changed musicSubscriptionOffer's isPresented binding to true while internal presentation state is loading(MusicSubscriptionOffer.Options(messageIdentifier: .join, itemID: 331661274, affiliateToken: ....)).
It's important to note I am displaying it from UIKit ObjC and so I had to go through some hoops in order to get this to working.
Here's the relevant code:
//
// MusicSubscriptionOfferView.swift
//
import Foundation
import MusicKit
import Combine
import SwiftUI
struct MusicSubscriptionOfferView: View {
@StateObject var viewModel = MusicSubscriptionOfferViewModel()
var body: some View {
EmptyView()
.musicSubscriptionOffer(
isPresented: $viewModel.isShowingOffer,
options: viewModel.offerOptions
)
}
}
class MusicSubscriptionOfferViewModel: NSObject, ObservableObject {
@Published var isShowingOffer = false
static var musicItemID: MusicItemID?
var canBecomeSubscriber = false
var offerOptions: MusicSubscriptionOffer.Options {
get {
var options = MusicSubscriptionOffer.Options()
options.affiliateToken = "..."
options.itemID = MusicSubscriptionOfferViewModel.musicItemID
return options
}
}
var subscriptions = Set<AnyCancellable>()
override init() {
super.init()
Task {
for await subscription in MusicSubscription.subscriptionUpdates {
MyApp.sharedInstance().canBecomeSubscriber = subscription.canBecomeSubscriber
}
}
NotificationCenter.default
.publisher(for: NSNotification.Name(K_SHOW_APPLE_MUSIC_SUBSCRIPTION))
.sink { [weak self] _ in
self!.isShowingOffer = true
}
.store(in: &subscriptions)
}
}
MusicSubscriptionOfferViewModel is initiated on launch, so MyApp.sharedInstance().canBecomeSubscriber receives a value upon launch.
and:
@objcMembers
final class MusicOfferProxyViewController: UIHostingController<MusicSubscriptionOfferView> {
required init() {
super.init(rootView: MusicSubscriptionOfferView())
}
@objc required dynamic init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
From the UIKit view controller:
MusicKitInterop* musicKitObject = [[MusicKitInterop alloc] init];
[self.view addSubview:musicKitObject.musicOfferProxyViewController.view];
[self addChildViewController:musicKitObject.musicOfferProxyViewController];
self.musicKitInterop = musicKitObject;
class MusicKitInterop: NSObject {
var musicOfferVC: MusicOfferProxyViewController
override init() {
musicOfferVC = MusicOfferProxyViewController()
}
@objc func musicOfferProxyViewController() -> UIViewController {
return musicOfferVC
}
@objc func canBecomeSubscriber() -> Bool {
return MyApp.sharedInstance().canBecomeSubscriber
}
}
So I understand that MusicItemID is a unique object identifier so for one specific artist; they have a different MusicItemID from Library than from Catalog.
But if I'm trying to implement a feature that allows users to add UNIQUE Artists to a list, whether it be from Library or Catalog; how am I supposed to differentiate between the Library Artist and Catalog Artist?
In this scenario, there is no way for me to identify that an Artist from Library is the same Artist from Catalog because the MusicItemID is not the same; so it's not possible for me to omit duplicates from the list as I cannot identify if they are representing the same Artist. This is an extremely big blocker as I want users to have the option to access from library and catalog.
I've looked over the documentation but can't find anything that would allow me to do this sort of mapping to match Artists between Library and Catalog. Using name comparison also is not a valid option as Artist names are not unique.
Any advice or workarounds would be appreciated, thank you.
Hi.
I am transitioning my app from using MPMediaQuery to using MusicLibraryRequest from MusicKit. This is working fine for playlists in the user's library.
I also allow my app users to play their podcasts. I currently use MPMediaQuery.podcasts(). Does anyone know if there is an equivalent using MusicLibraryRequest?
Cheers,
Ian