Post

Replies

Boosts

Views

Activity

Fetch tracks from a playlist
If an app allows people to create a playlist and add more songs to that created playlist, it would make sense to guard them from accidentally adding the same song to the playlist more than once. In this code, even though it is successfully receiving the existing playlist from the request, its tracks and entries always show as nil even when there are songs in the playlist. Any suggestions for how to guard against adding duplicates to a playlist? Thank you! var request = MusicLibraryRequest<Playlist>() request.filter(matching: \.name, equalTo: "AppGeneratedPlaylist") let response = try await request.response() if let existingPlaylist = response.items.first { if let tracks = existingPlaylist.entries, tracks.contains(where: { $0.id == song.id }) { print("Song is already in the playlist, so don't add again") return } else { try await MusicLibrary.shared.add(song, to: existingPlaylist) print("Added song to existing playlist: \(existingPlaylist.name)") print("Count of tracks: \(existingPlaylist.tracks?.count)") print("Count of entries: \(existingPlaylist.entries?.count)") print("Current tracks: \(existingPlaylist.tracks?.map(\.id))") print("Current entries: \(existingPlaylist.entries?.map(\.id))") } }
1
0
32
8h
MusicKit - ApplicationMusicPlayer fails to play certain Songs
[Note: this issue was happening on a main testing device, and after testing the same code on other devices, this issue is only happening on 1 out of 4 devices] We are successfully getting a MusicCatalogResourceResponse for every song ID where we make the MusicCatalogResourceRequest. We are able to display the song title, artist name, and album artwork for each Song in the response. However - when we go to play the song, there are some songs that play, and several songs that do not play. For the songs that don't play, the console shows “Failed to prepareToPlay error=<MPMusicPlayerControllerErrorDomain.6 "Failed to prepare to play" {}>” let musicPlayer = ApplicationMusicPlayer.shared func playSong(_ song: Song) { musicPlayer.queue = [song] Task { try await musicPlayer.prepareToPlay() try await musicPlayer.play() } Is there anything else we can investigate about what may be causing specific song IDs not to play on this specific device? Even if we remove line 6 musicPlayer.prepareToPlay() we still see the same console error when running playSong with the Songs that don't work. It is always the same song IDs that we can play and always the same song IDs that we cannot get to play, even trying them across different projects with different bundle identifiers. We can tap to play a song that works, and it starts playing immediately. Then tap a song that doesn't work, and nothing happens. Then back to a song that works. It's consistent which songs succeed and fail on this device. Perhaps there is an issue specific to this very iPad when it comes to certain specific songs, but we'd like to be confident that an app relying on MusicKit will be able to play songs that have been successfully loaded with a MusicCatalogResourceResponse. Thanks for any help or suggestions about what we may be able to investigate further on the device or what we should consider when launching an app that expects anyone with Apple Music to be able to listen to any of the songs loaded by the app. Specific iPad details: iPad Pro (12.9-inch) (6th generation) running iPadOS 26.4 Beta Two of the song IDs that won't play on this iPad (even though we can access and display their album artwork and all other information): 943204000 and 1441164805
2
1
720
Mar ’26
AVSpeechSynthesisVoices available on device
Hello there! Is there any list of voices that are always available on iOS/iPadOS devices? It seems that AVSpeechSynthesisVoice(identifier: "com.apple.voice.compact.en-US.Samantha") is always available on all devices. I thought that AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_Nicky_en-US_compact") and AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_Aaron_en-US_compact") were available by default on certain newer devices. Is this true? I also noticed that on the same iPad where I was using those 2 voices (Nicky and Aaron) - when I updated to the iPadOS 26 beta, those voices were no longer available. Any information you can share about which voices should be reliably available on which devices would be extremely helpful for our development. Thanks so much!
0
0
364
Jun ’25
Animating Text foregroundStyle with gradients
Hello! We can animate Text color via foregroundStyle very nicely in SwiftUI like so: Text("Some text here") .foregroundStyle(boolValue ? Color.green : Color.blue) withAnimation { boolValue.toggle() } However, if the foregroundStyle is a gradient, the color of the Text view changes immediately without animation. The code below works to animate a gradient foregroundStyle on an SF Symbol, but it does not work when applied to a Text view. Is it possible to animate a Text view foregroundStyle between gradient values? Image(systemName: "pencil.circle.fill") .foregroundStyle(boolValue ? .linearGradient(colors: [.red, .orange], startPoint: .top, endPoint: .bottom) : .linearGradient(colors: [.green, .blue], startPoint: .top, endPoint: .bottom)) Thanks for your help!
1
0
392
Mar ’25
Are win-back offers presented for the entire Subscription Group?
If I have a monthly subscription offering for an app and also a yearly subscription offering for the same app. And if I set up a win-back offer through App Store Connect on the yearly subscription offering. Will this win-back offer be shown to lapsed subscribers of both the monthly and yearly offerings? Or would it be necessary to create a different win-back offer for each offering if we want lapsed subscribers to see a win-back offer regardless of which subscription they had previously purchased? Thanks so much in advance!
1
0
608
Oct ’24
MusicKit Sample Code errors
In Xcode 13 beta 4, the Sample Code Using MusicKit to Integrate with Apple Music has compiler errors around the player.play() calls in handleTrackSelected and handlePlayButtonSelected. The error is "async call in a function that does not support concurrency / call can throw, but is not marked with try and the error is not handled" Would it be possible to include a fix for this error in the sample code - or could somebody share a fix here in the forums? Thanks so much!
5
0
1.4k
Aug ’21
Fetch tracks from a playlist
If an app allows people to create a playlist and add more songs to that created playlist, it would make sense to guard them from accidentally adding the same song to the playlist more than once. In this code, even though it is successfully receiving the existing playlist from the request, its tracks and entries always show as nil even when there are songs in the playlist. Any suggestions for how to guard against adding duplicates to a playlist? Thank you! var request = MusicLibraryRequest<Playlist>() request.filter(matching: \.name, equalTo: "AppGeneratedPlaylist") let response = try await request.response() if let existingPlaylist = response.items.first { if let tracks = existingPlaylist.entries, tracks.contains(where: { $0.id == song.id }) { print("Song is already in the playlist, so don't add again") return } else { try await MusicLibrary.shared.add(song, to: existingPlaylist) print("Added song to existing playlist: \(existingPlaylist.name)") print("Count of tracks: \(existingPlaylist.tracks?.count)") print("Count of entries: \(existingPlaylist.entries?.count)") print("Current tracks: \(existingPlaylist.tracks?.map(\.id))") print("Current entries: \(existingPlaylist.entries?.map(\.id))") } }
Replies
1
Boosts
0
Views
32
Activity
8h
MusicKit - ApplicationMusicPlayer fails to play certain Songs
[Note: this issue was happening on a main testing device, and after testing the same code on other devices, this issue is only happening on 1 out of 4 devices] We are successfully getting a MusicCatalogResourceResponse for every song ID where we make the MusicCatalogResourceRequest. We are able to display the song title, artist name, and album artwork for each Song in the response. However - when we go to play the song, there are some songs that play, and several songs that do not play. For the songs that don't play, the console shows “Failed to prepareToPlay error=<MPMusicPlayerControllerErrorDomain.6 "Failed to prepare to play" {}>” let musicPlayer = ApplicationMusicPlayer.shared func playSong(_ song: Song) { musicPlayer.queue = [song] Task { try await musicPlayer.prepareToPlay() try await musicPlayer.play() } Is there anything else we can investigate about what may be causing specific song IDs not to play on this specific device? Even if we remove line 6 musicPlayer.prepareToPlay() we still see the same console error when running playSong with the Songs that don't work. It is always the same song IDs that we can play and always the same song IDs that we cannot get to play, even trying them across different projects with different bundle identifiers. We can tap to play a song that works, and it starts playing immediately. Then tap a song that doesn't work, and nothing happens. Then back to a song that works. It's consistent which songs succeed and fail on this device. Perhaps there is an issue specific to this very iPad when it comes to certain specific songs, but we'd like to be confident that an app relying on MusicKit will be able to play songs that have been successfully loaded with a MusicCatalogResourceResponse. Thanks for any help or suggestions about what we may be able to investigate further on the device or what we should consider when launching an app that expects anyone with Apple Music to be able to listen to any of the songs loaded by the app. Specific iPad details: iPad Pro (12.9-inch) (6th generation) running iPadOS 26.4 Beta Two of the song IDs that won't play on this iPad (even though we can access and display their album artwork and all other information): 943204000 and 1441164805
Replies
2
Boosts
1
Views
720
Activity
Mar ’26
AVSpeechSynthesisVoices available on device
Hello there! Is there any list of voices that are always available on iOS/iPadOS devices? It seems that AVSpeechSynthesisVoice(identifier: "com.apple.voice.compact.en-US.Samantha") is always available on all devices. I thought that AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_Nicky_en-US_compact") and AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_Aaron_en-US_compact") were available by default on certain newer devices. Is this true? I also noticed that on the same iPad where I was using those 2 voices (Nicky and Aaron) - when I updated to the iPadOS 26 beta, those voices were no longer available. Any information you can share about which voices should be reliably available on which devices would be extremely helpful for our development. Thanks so much!
Replies
0
Boosts
0
Views
364
Activity
Jun ’25
Animating Text foregroundStyle with gradients
Hello! We can animate Text color via foregroundStyle very nicely in SwiftUI like so: Text("Some text here") .foregroundStyle(boolValue ? Color.green : Color.blue) withAnimation { boolValue.toggle() } However, if the foregroundStyle is a gradient, the color of the Text view changes immediately without animation. The code below works to animate a gradient foregroundStyle on an SF Symbol, but it does not work when applied to a Text view. Is it possible to animate a Text view foregroundStyle between gradient values? Image(systemName: "pencil.circle.fill") .foregroundStyle(boolValue ? .linearGradient(colors: [.red, .orange], startPoint: .top, endPoint: .bottom) : .linearGradient(colors: [.green, .blue], startPoint: .top, endPoint: .bottom)) Thanks for your help!
Replies
1
Boosts
0
Views
392
Activity
Mar ’25
Are win-back offers presented for the entire Subscription Group?
If I have a monthly subscription offering for an app and also a yearly subscription offering for the same app. And if I set up a win-back offer through App Store Connect on the yearly subscription offering. Will this win-back offer be shown to lapsed subscribers of both the monthly and yearly offerings? Or would it be necessary to create a different win-back offer for each offering if we want lapsed subscribers to see a win-back offer regardless of which subscription they had previously purchased? Thanks so much in advance!
Replies
1
Boosts
0
Views
608
Activity
Oct ’24
MusicKit Sample Code errors
In Xcode 13 beta 4, the Sample Code Using MusicKit to Integrate with Apple Music has compiler errors around the player.play() calls in handleTrackSelected and handlePlayButtonSelected. The error is "async call in a function that does not support concurrency / call can throw, but is not marked with try and the error is not handled" Would it be possible to include a fix for this error in the sample code - or could somebody share a fix here in the forums? Thanks so much!
Replies
5
Boosts
0
Views
1.4k
Activity
Aug ’21