Skip to content

Instantly share code, notes, and snippets.

@phucnm
Created March 7, 2016 09:45
Show Gist options
  • Save phucnm/4f68c8760ffe5ddc60b0 to your computer and use it in GitHub Desktop.
Save phucnm/4f68c8760ffe5ddc60b0 to your computer and use it in GitHub Desktop.
Play video with AVPlayer
NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = player;
[self presentViewController:playerViewController animated:YES completion:nil];
NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:playerLayer];
[player play];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment