Change AVPlayerViewController background to album artwork objective-c iOS

大憨熊 提交于 2019-12-23 15:13:28

问题


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];

回答1:


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 :)



来源:https://stackoverflow.com/questions/37298000/change-avplayerviewcontroller-background-to-album-artwork-objective-c-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!