Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change AVPlayerViewController background to album artwork objective-c iOS

Is it possible to change the background of an AVPlayerViewController instance when playing audio ?

When I lock my device, I can see the music controls with album artwork correctly shown but when the AVPlayerViewController is shown in my app, I can only see the controls with a background representing QuickTime currently playing.

Here is how I call it :

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];


        NSURL *url=[NSURL fileURLWithPath:clickedPath];
        AVPlayer *player = [AVPlayer playerWithURL:url];


        AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
        [self presentViewController:controller animated:YES completion:nil];
        controller.player = player;
        [player play];
like image 986
Synny Avatar asked May 18 '16 11:05

Synny


1 Answers

Yes you can customize AVPlayerViewController by customizing it's contentOverlayView.

You can customise contentOverlayView.

see the Apple documentation, it states

You can use the content overlay view to add additional custom views between the video content and the playback controls.

for example,

  AVPlayerViewController *controller =  [[AVPlayerViewController alloc] init];

[controller.contentOverlayView setBackgroundColor:[UIColor greenColor]];

like wise you can add other controls like button,label etc to that contentOverlayView.

Hope this will help :)

like image 52
Ketan Parmar Avatar answered Oct 14 '22 04:10

Ketan Parmar