Gaby Fitcal
Gaby Fitcal

Reputation: 1954

Hide next track/slide duration from Now Playing

I have a radio App, and i playing it with AVPlayer.

I display the Name radio in MPNowPLaying.

I want hide button next/previous track and slide bar with PLayback Duration. How can i do it? I want display like in pictures below:

enter image description here

enter image description here

Upvotes: 1

Views: 1105

Answers (1)

Quentin Hayot
Quentin Hayot

Reputation: 7876

You can't hide them. But starting in iOS 7.1 you can disable them:

// Disable previous track button
[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = NO;
// Disable next track button
[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand.enabled = NO;

For the playback duration, just don't set anything for MPMediaItemPropertyPlaybackDuration in your [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:]

On top of that, you can show custom info (and even an artwork) on the now playing screen:

NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
[songInfo setObject:someTitle forKey:MPMediaItemPropertyTitle];
[songInfo setObject:someArtist forKey:MPMediaItemPropertyArtist];
[songInfo setObject:someAlbum forKey:MPMediaItemPropertyAlbumTitle];

MPMediaItemArtwork *albumArt;
if (song.artwork){
    albumArt = [[MPMediaItemArtwork alloc] initWithImage: someArtwork];
}
else {
    albumArt = [[MPMediaItemArtwork alloc] init]; // make sure to remove the artwork if none is found for the current track
}
[songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];

Upvotes: 3

Related Questions