0

I have a music app I have coded using Swift and I have found a bug that Apple has acknowledged as a bug on their end.

In the app I can tap a button and play songs based on the currently playing song. I am using prepend to create queue's. So for example when I want to add a specific genre to the queue I use

let lockArtist = MediaManager.shared.getSongsWithCurrentArtistFor(item: nowPlaying)
if var items = lockArtist.items {
    items.shuffle()
    let descriptor =  MPMusicPlayerMediaItemQueueDescriptor(itemCollection:  MPMediaItemCollection(items: items))
  self.mediaPlayer.prepend(descriptor)
}

The MediaManager.shared.getSongsWithCurrentArtistFor is

func getSongsWithCurrentArtistFor(item: MPMediaItem) -> MPMediaQuery {
  let artistPredicate = MPMediaPropertyPredicate(value: item.artist, forProperty: MPMediaItemPropertyArtist, comparisonType: .contains)
  let query = MPMediaQuery()
  query.addFilterPredicate(artistPredicate)
  return query
}

.

This code works! It adds the genre to the queue but it does not keep track of the queue. I'll explain

.

What I expect to happen is song 1 comes on, then song 2, then song 3, and so on. From Song 3 if I tapped the back button I would expect to go back to song 2 and then the forward button would go forward to song 3.

What actually happens is song 1 comes on, then song 2, then song 3 and when I tap the back button from song 3 it DOES NOT go back to song 2 but instead a random song and tapping the forward button does not go to song 3 but another random song.

The first back song button tap will usually stay within the genre but the next will go to the song I was playing before I tapped the button that used the prepend code.

I filed a code level support ticket with Apple and after a while the engineer said the issue is not with me but on Apple's end and instructed me to file a bug report also and include the ticket # and they would help find a work around. That was **2 months* ago and I never heard back.

I was hoping somebody could help.

RubberDucky4444
  • 2,330
  • 5
  • 38
  • 70
  • And what do you want from us? It's a bug. It's an acknowledged bug. You could look to see whether it's fixed in iOS 12 beta, but apart from that, you're done. This is not a Stack Overflow matter (except that it's interesting, of course, to hear about the bug). – matt Jun 14 '18 at 19:04
  • Well, @matt, there are other music apps on the App Store and if they are using prepend they seem to have found a work around. – RubberDucky4444 Jun 14 '18 at 19:08
  • But they are presumably not using `prepend` with `MPMusicPlayerMediaItemQueueDescriptor(itemCollection:)` which is where the bug lies. – matt Jun 14 '18 at 19:08
  • Voting to close on the basis that this is the same bug about the uselessness of `MPMusicPlayerMediaItemQueueDescriptor(itemCollection:)` that I talked about long ago, but let me know if you think it isn't. :) – matt Jun 14 '18 at 19:10
  • 1
    And heres why I dread asking on SO. Questions closed because it slightly resembles a question already asked leading to a toxic community. Thanks @matt – RubberDucky4444 Jun 14 '18 at 19:13
  • Well I said I'd be happy to be told it isn't the same bug. But I'm pretty sure it is. Basically `MPMusicPlayerMediaItemQueueDescriptor(itemCollection:)` is just hosed and can't be used successfully for anything. Don't shoot the messenger! I don't like it any more than you do. – matt Jun 14 '18 at 19:15

0 Answers0