将AVPlayerViewController背景更改为专辑插图Objective-C iOS [英] Change AVPlayerViewController background to album artwork objective-c iOS

查看:122
本文介绍了将AVPlayerViewController背景更改为专辑插图Objective-C iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

这是我的称呼:

[[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.

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

您可以自定义contentOverlayView.

请参见 Apple文档,其中指出

您可以使用内容覆盖视图在视频内容和播放控件之间添加其他自定义视图.

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上添加其他控件,例如按钮,标签等.

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

希望这会有所帮助:)

这篇关于将AVPlayerViewController背景更改为专辑插图Objective-C iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆