ios – AVPlayer全屏

我在我的应用程序中使用AVPlayer而不是MPMoviePlayerController,因为我想将播放器作为子图层.
但是我需要控制,如播放,暂停,搜索和全屏.如何在AVPlayer中获得该按钮?
这就是我放置玩家的方式:
AVURLAsset *avasset = [[AVURLAsset alloc] initWithURL:URL1 options:nil];

    AVPlayerItem *item = [[AVPlayerItem alloc] initWithAsset:avasset];
    player = [[[AVPlayer alloc] initWithPlayerItem:item]retain];

    playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
    CGSize size = self.view.bounds.size;
    float x = size.width/2.0-187.0;
    float y = size.height/2.0 - 125.0;

    playerLayer.frame = CGRectMake(x,y,474,320);
    [playerLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
    [self.view.layer addSublayer:playerLayer];
    [player play];

解决方法

你必须提供自己的按钮.

对于playpause,AVPlayer中有直接的API.

对于全屏……嗯……你知道你在哪里画画:你只需要调整你的UIWindow和相应的UIView&图层为全尺寸.

对于搜索,你有像seekToTime:这样的方法

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...