Created
August 11, 2018 15:21
-
-
Save jawngee/f618d39ddc428e4492813865c7c02789 to your computer and use it in GitHub Desktop.
Background Looping Video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import AVFoundation; | |
@import AVKit; | |
AVQueuePlayer *player = [[AVQueuePlayer alloc] init]; | |
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; | |
playerLayer.frame = self.bounds; | |
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; | |
[self.layer addSublayer:playerLayer]; | |
[player pause]; | |
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:[NSBundle.mainBundle URLForResource:@"movie" withExtension:@"mov"]]; | |
AVPlayerLooper* looper = [AVPlayerLooper playerLooperWithPlayer:player templateItem:playerItem]; | |
[player play]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment