MusicKit

RSS for tag

Let users play Apple Music and their local music library from your app using MusicKit.

Posts under MusicKit tag

115 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Disable MusicKit logs without disabling manual Logs via Logger()
I want to switch from using print statements to using OSLog because of the filtering options and so on. I am using MusicKit. To mute all the log noise mostly coming from CoreData I pass these arguments on launch: -com.apple.CoreData.SQLDebug 0 -com.apple.CoreData.MigrationDebug 0 -com.apple.CoreData.ConcurrencyDebug 0 -com.apple.CoreData.CloudKitDebug 0 -com.apple.CoreData.Logging.stderr 0 This works for all the Core Data related warnings but I also need such an argument for MusicKit. Setting the environment variable OS_ACTIVITY_MODE to disable hides all the noise but also hides the log statements I sent via Logger().debug() for example. In particular these log messages appear in great quantities. Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.iTunesStore" )} <ICMonitoredAccountStore: 0x303c5c9f0> Failed to register for account monitoring. err=Error Domain=com.apple.accounts Code=7 "(null)" My application works fine and these log messages mean absolutely nothing to me. These two threads mention a similar problem but can't offer a solution. https://forums.developer.apple.com/forums/thread/720835 https://forums.developer.apple.com/forums/thread/743795 Thank you
2
0
374
Sep ’24
ApplicationMusicPlayer.shared doesn't play explicit content on MacCatalyst
I am developing an app running on iOS/iPadOS and on macOS using MacCatalyst. It uses ApplicationMusicPlayer.shared to play music from Apple Music. However, on the Mac songs with contentRating == .explicit do not work. I will get the following error (sorry, German localization): Failed to prepareToPlay error=<MPMusicPlayerControllerErrorDomain.6 "Failed to prepare to play" {}> Error playing item: Der Vorgang konnte nicht abgeschlossen werden. (MPMusicPlayerControllerErrorDomain-Fehler 6.) On iOS/iPadOS these songs play correctly. What can I do to also play explicit songs using MacCatalyst? Thanks, Dirk
1
0
330
Aug ’24
ApplicationMusicPlayer's endSeeking() Fails to Stop Fast Forward - Seeking Solutions
I've encountered a critical issue while developing a music player app using SwiftUI and MusicKit. The problem persists across multiple devices and iOS versions, specifically with the endSeeking() method of ApplicationMusicPlayer, which fails to stop the fast-forward operation as expected. Development Environment: Xcode 16 Beta 6 macOS Sonoma 15.0 Beta 7 (24A5327a) Affected Devices: iPhone 11 Pro Max (iOS 17.6) iPhone SE 3 (iOS 18.0 Beta 7) Here's the relevant code snippet: Image(systemName: "forward.end.circle") .foregroundStyle(.accent) .gesture( TapGesture() .onEnded { _ in vm.nextTrack() } ) .simultaneousGesture( LongPressGesture(minimumDuration: 0.5) .onChanged { isPressing in if isPressing { vm.player.beginSeekingForward() } } .onEnded { _ in vm.player.endSeeking() } ) The issue manifests when the long press ends: despite invoking the endSeeking() method, the fast-forward operation persists. To troubleshoot, I've taken the following steps: Confirmed that vm.player is set to ApplicationMusicPlayer.shared. Attempted to combine endSeeking() with beginSeekingForward(), as per the documentation guidelines. Despite these efforts, the problem persists across all tested devices and OS versions. This leads me to two critical questions: Has anyone else encountered a similar issue? Could this potentially be an undocumented bug in the latest MusicKit implementation?
2
1
337
Sep ’24
Unknown throws value for method in MusicKit
I'm working on an application that uses MusicKit and I'm trying to access Artists that are in a user's library. When I create the library request then call response(), I can see that it throws. The issue is I don't know what kind of errors can be thrown from this method. Are there specific errors in the MusicKit library that I should expect? let request = MusicLibraryRequest<Artist>() do { let response = try await request.response() return .success(response.items) } catch let error { // what are the possible instances for this error?! return .failure(.unknown(error: error)) }
1
0
261
Aug ’24
ApplicationMusicPlayer Audio Session Issue When Switching to AVAudioEngine in Background
Hi! I'm developing a music player app that interchanges between ApplicationMusicPlayer and AVAudioEngine. I'm facing an issue when switching from playback via ApplicationMusicPlayer to AVAudioEngine while the app is in background. Based on testing, it seems like the issue has to do with being unable to set audio focus in background, causing error AVAudioSessionErrorCodeCannotInterruptOthers. I would like to check if ApplicationMusicPlayer has its own audio focus separated from the app's own audio focus. If it is, is there anything that I can do to ensure that ApplicationMusicPlayer returns focus to the app? (I notice that the issue does not occur if we are moving playback from AVAudioEngine to ApplicationMusicPlayer. Not sure why the opposite does not work)
1
0
388
Aug ’24
MusicKit Preview Assets without Music Library Access
Hi, I want to embed song previews in my app when a user shares an apple music link. While using MusikKit getting previews seems to require access to the iCloud Music library, even though I‘m not shure how this is related, since I‘m not acessing user data. Is there any possibility that makes the preview work while neither requiring access to the users library nor a signed jwt?
0
0
286
Aug ’24
Watchdog kills the app with 0x8BADF00D because of MusicKit activity
After integration with MusicKit, I have an issue with Watchdog. The crash log point on this stack trace: ProcessState: Running WatchdogEvent: scene-update WatchdogVisibility: Background WatchdogCPUStatistics: ( "Elapsed total CPU time (seconds): 72.560 (user 49.970, system 22.590), 39% CPU", "Elapsed application CPU time (seconds): 11.270, 6% CPU" ) reportType:CrashLog maxTerminationResistance:Interactive> Triggered by Thread: 0 Thread 0 Crashed: 0 libsystem_kernel.dylib 0x1dfa74808 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x1dfa78008 mach_msg2_internal + 80 2 libsystem_kernel.dylib 0x1dfa77f20 mach_msg_overwrite + 436 3 libsystem_kernel.dylib 0x1dfa77d60 mach_msg + 24 4 libdispatch.dylib 0x19e884b18 _dispatch_mach_send_and_wait_for_reply + 544 5 libdispatch.dylib 0x19e884eb8 dispatch_mach_send_with_result_and_wait_for_reply + 60 6 libxpc.dylib 0x1f386bac8 xpc_connection_send_message_with_reply_sync + 264 7 Foundation 0x195853998 __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16 8 Foundation 0x195850004 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2160 9 Foundation 0x1958c820c -[NSXPCConnection _sendSelector:withProxy:arg1:] + 116 10 Foundation 0x1958c7e80 _NSXPCDistantObjectSimpleMessageSend1 + 60 11 MediaPlayer 0x1a8c0ff24 -[MPMusicPlayerController _validateServer] + 128 12 MediaPlayer 0x1a8c3f4f8 -[MPMusicPlayerApplicationController _establishConnectionIfNeeded] + 2144 13 MediaPlayer 0x1a8c0fbb8 -[MPMusicPlayerController onServer:] + 52 14 MediaPlayer 0x1a8c0ec94 -[MPMusicPlayerController _nowPlaying] + 372 15 MediaPlayer 0x1a8c161a4 -[MPMusicPlayerController nowPlayingItem] + 24 16 MusicKit 0x213253e78 -[MusicKit_SoftLinking_MPMusicPlayerController nowPlayingItem] + 24 17 MusicKit 0x2136ec1bc 0x2131b9000 + 5452220 18 MusicKit 0x2136ec70c 0x2131b9000 + 5453580 19 MusicKit 0x2136ed839 0x2131b9000 + 5457977 20 MusicKit 0x213221c65 0x2131b9000 + 429157 21 MusicKit 0x21354b741 0x2131b9000 + 3745601 22 libswift_Concurrency.dylib 0x1a1d0e775 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 According to the log - the app is in the background and the stack trace has only MusicKit. How could we disable or avoid this activity to avoid the Watchdog issue?
0
0
400
Jul ’24
MPMusicPlayerControllerErrorDomain error 6
I have a user who is reporting an error and has been kind enough to share screen recordings to help diagnose. I am not experiencing this error, nor am I able to replicate on other devices I've tried, so I'm stuck trying to fix. His & other devices tested were all running iOS 17.5.1. Any details on the cause of this error or potential workarounds I could use to resolve would be greatly appreciated. try await ApplicationMusicPlayer.shared.play() throws: The operation couldn't be completed (MPMusicPlayerControllerErrorDomain error 6.) MusicAuthorization.currentStatus is .authorized ApplicationMusicPlayer.shared.isPreparedToPlay is false ApplicationMusicPlayer.shared.queue.currentEntry is nil (I've noticed this to be the case even when I am able to successfully play as well) Queue was loaded using ApplicationMusicPlayer.shared.queue = [album] but I also tried ApplicationMusicPlayer.shared.queue = ApplicationMusicPlayer.Queue(album:startingAt:) and it made no difference. album.playParameters are correct. He experiences the error when attempting to play any album. Any and all help is truly appreciated. Feedback Assistant filed has gone unanswered.
2
0
426
Sep ’24
MusicKit iOS17.5 and iOS18
Good morning, I'm trying to use MusicKit functionalities in order to get last played songs and put them into a local DB, to be played later. Following the guide on developer.apple.com, I created the required AppServices integration: Below is a minimal working version of what I'm doing: func requestMusicAuthorization() async { let status = await MusicAuthorization.request() switch status { case .authorized: isAuthorizedForMusicKit = true error = nil case .restricted: error = NSError(domain: "Music access is restricted", code: -10) case .notDetermined: break case .denied: error = NSError(domain: "Music access is denied", code: -10) @unknown default: break } } on the SwiftUI ContentView there's something like that: .onAppear { Task { await requestMusicAuthorization() if MusicManager.shared.isAuthorizedForMusicKit { let response = try await fetchLastSongs() do { let request = MusicRecentlyPlayedRequest<Song>() let response = try await request.response() var songs: [Song] = response.items.map { $0 } // do some CloudKit handling with songs... print("Recent songs: \(songs)") } catch { NSLog(error.localizedDescription) } } } } Everything seems to works fine, but my console log is full of garbage like that: MSVEntitlementUtilities - Process MyMusicApp PID[33633] - Group: (null) - Entitlement: com.apple.accounts.appleaccount.fullaccess - Entitled: NO - Error: (null) Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.iTunesStore" )} is there something I'm missing on? Should I ignore that and go forward with my implementation? Any help is really appreciated.
1
0
589
Jul ’24
Integrating Apple Music Subscriptions into a React Native App
Hi everyone, I'm currently developing an iOS app using React Native and recently got accepted into the Apple Music Global Affiliate Program. To fully utilize this opportunity, I need to implement the following functionalities: Authorize Apple Music usage Play Apple Music within my app Identify if a user has an Apple Music subscription Initiate and complete Apple Music subscription within my app I've successfully implemented the first three functionalities using the react-native-apple-music module. Now, I need your help to understand how I can directly trigger the Apple Music subscription process from within my app. Thank you for your help!
0
1
539
Jun ’24
Audio transition using MPMusicPlayerApplicationController
Hi. I saw that in iOS 18 Beta there is a property "transition" on the Music Kit's ApplicationMusicPlayer. However, in my app I am using MPMusicPlayerApplicationController because I want to play Apple Music songs, local songs and podcasts. But I didn't find an analogue property on MPMusicPlayerApplicationController to specify transitions between songs. Am I missing something? Thanks, Dirk
0
0
446
Jun ’24
Music Kit for web app
Hello there, I am faced with the following situation: We are building a web app that manages playlists for different platforms, including Apple music We have the concept of teams in there, where a user can be part of multiple teams, and teams are managed by team admin A team admin could manage multiple teams The problem here is, that a team admin wouldn't be able to sign in to the Apple music account for multiple teams because if using the same computer we try to let the user sign in once and store the Music User Token, we can't do another login unless we unauthorized the previous one. Is there anything we can do about this? Thanks
1
0
622
Jun ’24
MusicKit Content Rights, Age Rating and App Encryption
I built an app that makes playing audio plays easier using MusicKit. Now I am about to release the app to the app store. Following questions occured while doing so: Am I accessing/showing third party content in my app when I am music (in this case radio plays) from MusicKit? I am getting all of that data directly from Apple. Is Apple a third party in this case? The publisher has an app that can playback all of the content that can be accessed in my app. This app has an age rating of 4+ years. Can I just copy that? I've heard that referring to other apps doesn't convince the App Review Team if they disagree. None of the titles are marked explicit in Apple Music. Under the hood MusicKit is using HTTPS to get the data from Apple's servers. I have no code that has anything to do with encryption or HTTPS. Does my app still uses Non Exempt Encryption because MusicKit does so? Can I access music through MusicKit that is otherwise not available in this region or does MusicKit take care of this for me? In other words do I have to restrict the availability of my app to certain regions so I don't bypass any geo blockings by accident? Thank you
0
0
471
May ’24