NSString *urlPath; NSURL *videoUrl; urlPath = [[NSBundle mainBundle] pathForResource:@"fogLoop" ofType:@"mp4"]; videoUrl = [NSURL fileURLWithPath:urlPath]; avPlayer = [AVPlayer playerWithURL:videoUrl]; avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer]; avPlayerLayer.frame = videoView.layer.bounds; avPlayerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; [videoView.layer addSublayer: avPlayerLayer]; avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[avPlayer currentItem]]; [avPlayer play];
I have several UILabels on this view. I just want the video as a background element really. With this code, it seems to reproduce all the user interface elements. How to make him go to the background?
ios objective-c avplayer
objectiveccoder001
source share