简单视频播放AVPlayer和AVPlayerViewController

    NSURL *url = [NSURL URLWithString:@"http://flv3.bn.netease.com/videolib3/1712/13/ouwHf3421/SD/ouwHf3421-mobile.mp4"];

    AVPlayer *avPlayer= [AVPlayer playerWithURL:url];

    // player的控制器对象

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

    // 控制器的player播放器

    playerViewController.player = avPlayer;

    // 试图的填充模式

    playerViewController.videoGravity = AVLayerVideoGravityResizeAspect;

    // 是否显示播放控制条

    playerViewController.showsPlaybackControls = YES;

    // 设置显示的Frame

    playerViewController.view.frame = CGRectMake(0, 173, WEIDTH, HEIGHT-173);

    // view一定要添加,否则将不显示

    [self.view addSubview:playerViewController.view];

    // 播放

    [playerViewController.player play];

你可能感兴趣的:(AVPlayer)