5

I am playing a audio file in iOS app using AVQueuePlayer/AVFoundation. i have set the MPNowPlayingInfoCenter's now playing information like album title, artist, Artwork, like this

NSMutableDictionary *albumInfo = [[NSMutableDictionary alloc] init];
MPMediaItemArtwork *artworkP;
UIImage *artWork = [UIImage imageNamed:album.imageUrl];
[albumInfo setObject:album.title forKey:MPMediaItemPropertyTitle];
[albumInfo setObject:album.auther forKey:MPMediaItemPropertyArtist];
[albumInfo setObject:album.title forKey:MPMediaItemPropertyAlbumTitle];
[albumInfo setObject:artworkP forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:albumInfo]

and also accessing remote event in application delegate for play,pause, next, previous event from lock screen. But the seek bar is not accessible, even i didn't find any option to set seek property.

i want to set seek property and want to access the seek slider change event in my app.

Here is the screen capture of lock screen.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Samir
  • 902
  • 9
  • 23

2 Answers2

0

I believe the only way to support forward and backward seeking is by the previous/advance buttons (they send a begin/end seeking notification when held down).

UIEventSubtypeRemoteControlBeginSeekingBackward, UIEventSubtypeRemoteControlBeginSeekingForward, 
UIEventSubtypeRemoteControlEndSeekingBackward, UIEventSubtypeRemoteControlEndSeekingForward

Based on some of the other questions and documentation the seek bar is only accessible via Apple's own apps (https://stackoverflow.com/a/20142141/535632, https://stackoverflow.com/a/20909875/535632). According to that last answer, it appears some apps (notably Spotify) route their music through the music player to utilize the seek bar.

Community
  • 1
  • 1
Jayson Lane
  • 2,828
  • 1
  • 24
  • 39
  • i have done customized seeking within app, but not when device is on sleep mode/locked. i haven't checked Spotify app yet, but if it does than it uses MPMusicPlayerController and loads songs from music library (songs stored in device). Same way scrobbler does. b'cos MPMusicPlayer class uses iPod's shared library.(http://bit.ly/MPMusicPlayer) MPMusicPlayer has its own class implementation provided by apple so it would behaves like native player. But if we want to play audio from our app, we will use AVFoundation classes. so i think we can not provide seek bar at lock screen in this case. – Samir Feb 06 '14 at 12:40
0

You can use MPRemoteCommandCenter after iOS 7

Robert
  • 470
  • 4
  • 12