MusicKit

RSS for tag

Let 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

SDK or API limitations/timeouts on 'unattended' use of an Apple Music-interface app
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?)
0
0
320
Dec ’23
Tracks from user library play out of order, macOS 14
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
1
0
295
Dec ’23
mediaPlaybackError callback never fires
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!
1
0
434
Dec ’23
Apple Music API Extended Features - UPDATE/DELETE
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,
0
0
462
Dec ’23
Catalyst - Cannot play media with SystemMusicPlayer
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() } } }
2
1
545
Nov ’23
Android Music SDK published to maven
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?
0
0
332
Nov ’23
Bring Back Gapless Playback
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.
0
0
428
Nov ’23
Get all local music from iPhone Same Like UIDocumentPicker Without UserInteraction
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.
0
0
500
Nov ’23
MusicKit / macOS : Song.Artwork not nil when there is no Artwork
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!
0
0
369
Oct ’23
How to trigger music playback in Widget
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?
1
0
657
Oct ’23
Apple Music Web Kit
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.
1
0
614
Sep ’23
Play only downloaded tracks in a playlist
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(...)?
0
0
379
Sep ’23
BUG IN APPLE MUSIC
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.
1
0
307
Sep ’23
MusicKit subscription page crashes
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 } }
1
0
410
Sep ’23
MusicKit: Artist MusicItemID is not the same between Library and Catalog. Is there a way to map them?
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.
0
0
339
Sep ’23
MusicLibraryRequest for podcasts
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
0
0
360
Sep ’23