4

Having problems setting currentPlaybackTime with MPMusicPlayerController in iOS 7.1. I used to be able to simply do the following:

MPMusicPlayerController *iPodController =
[MPMusicPlayerController applicationMusicPlayer]; 
iPodController.currentPlaybackTime = 30.0;
[iPodController play];

And the music player would seek to 30 seconds in and play.

As of iOS 7.1 this is not the case.

If I do the following:

[iPodController play];
iPodController.currentPlaybackTime = 30.0;

Then it "may" jump 30 secs in or not. Very inconsistent.

This used to work for all previous iOS versions. Is there a way to fix this?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Aron Nelson
  • 838
  • 1
  • 9
  • 17
  • Speculation: If the song is required to be playing before setting the currentPlayBackTime works, the successive calls to play and setCurrentPlayBackTime might be happening to quickly. The Player might not have changed it's state to playing. – Niels Castle Mar 24 '14 at 07:37
  • A deleted answer suggested setting `initialPlaybackTime` instead. – ivan_pozdeev Sep 16 '14 at 11:57

1 Answers1

0

I find that I can't set currentPlaybackTime before playing a given song.

Using your first snippet:

iPodController.currentPlaybackTime = 30.0;
[iPodController play];

setting the currentPlaybackTime property does nothing and I can't seek to the desired playback time. But making the calls the other way around have worked consistently for me with iOS 7.1 so far:

[iPodController play];
iPodController.currentPlaybackTime = 30.0;
Niels Castle
  • 8,039
  • 35
  • 56
  • 1
    Niels, for some people, calling the play function then setting currentPlaybackTime will cause the player to play the beginning, then jump to 30 after a second or so. I think there is no resolution since it seems currentPlayBackTime has been deprecated a while ago. I have this working with AVPlayer but as has been mentioned, AVPlayer will not play FairPlay protected files. Very frustrating. – Aron Nelson Mar 25 '14 at 16:52