小编use*_*429的帖子

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];
Run Code Online (Sandbox Code Playgroud)

objective-c ios avplayer avplayerlayer

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

avplayer ×1

avplayerlayer ×1

ios ×1

objective-c ×1