AMI amitekh AMI amitekh - 8 months ago 74
Objective-C Question

How to set AVPlayer controller in lock mode iOS

How to set background iOS media AVPlayer Like this
enter image description here

Left and right hand side players are needed.

Till now what I Have Achieved is enter image description here

All the

play pause previous next
are working, But I need to display
songName, artistName, albumArt, seekBar.

How to do that? Please provide any articles


you need to set information in MPNowPlayingInfoCenter like this.

 Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");

    if (playingInfoCenter) {

        NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];

        MPMediaItemArtwork *albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imageNamed:@"AlbumArt"]];

        NSArray *keys = [NSArray arrayWithObjects:

        NSError *playerError;

//        AVAudioPlayer*   audioPlayer4 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"This That (Dil Wali Gal) - Ammy Virk (DJJOhAL.Com)" ofType:@".mp3"]] error:&playerError];
//        NSLog(@"%f",audioPlayer4.duration);

        NSArray *values = [NSArray arrayWithObjects:
                           @"DIL vali gal",
                           @"ammy virk",
                           [NSNumber numberWithInt:1],
        NSDictionary *mediaInfo = [NSDictionary dictionaryWithObjects:values forKeys:keys];

        [songInfo setObject:@"Audio Title" forKey:MPMediaItemPropertyTitle];
        [songInfo setObject:@"Audio Author" forKey:MPMediaItemPropertyArtist];
        [songInfo setObject:@"Audio Album" forKey:MPMediaItemPropertyAlbumTitle];
        [songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
        [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo];


and import this frameworks

#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MPMoviePlayerController.h>