我正在用objective制作一个iOS应用程序。
请告诉我如何在iOS13.x环境中修复AVPlayerView。
M写
AVPlayerLayer* layer = (AVPlayerLayer*)self.videoView.layer;VideoView包含AVPlayerView
AVPlayerView.m写
#import "AVPlayerView.h"
#import <AVFoundation/AVFoundation.h>
@implementation AVPlayerView
+(Class)layerClass{
return AVPlayerLayer.class;
}
@end由于某些原因,不需要调用layerClass方法。
另外,(AVPlayerLayer *) self.videoView.layer返回的类
AVPresentationVontainerViewLayer。
我想要一个AVPlayerView课程。
我该怎么修呢?
发布于 2019-10-04 11:11:13
试试这个:
NSURL *url = [NSURL fileURLWithPath:path];
AVPlayer *player = [AVPlayer playerWithURL:url];
AVPlayerViewController *AVPlayerVc = [[AVPlayerViewController alloc] init];
AVPlayerVc.player = player;
if (AVPlayerVc) {
[self presentViewController:AVPlayerVc animated:YES completion:^{
[player play];
}];
}迅捷版:
let player = AVPlayer(url: YOUR_URL)
let playerController = AVPlayerViewController()
playerController.player = player
present(playerController, animated: true) {
player.play()
}https://stackoverflow.com/questions/58235211
复制相似问题