将 AVPlayerViewController 背景更改为专辑插图 objective-c iOS

Change AVPlayerViewController background to album artwork objective-c iOS

是否可以在播放音频时更改 AVPlayerViewController 实例的背景?

当我锁定我的设备时,我可以看到带有专辑插图的音乐控件正确显示,但是当我的应用程序中显示 AVPlayerViewController 时,我只能看到带有表示当前正在播放的 QuickTime 的背景的控件。

我是这样称呼它的:

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

是的,您可以通过自定义 contentOverlayView 来自定义 AVPlayerViewController

您可以自定义contentOverlayView

查看 Apple documentation,它指出

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

例如,

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

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

同样,您可以向其中添加其他控件,例如按钮、标签等 contentOverlayView

希望这会有所帮助:)