How can I check if my AVPlayer is buffering?

You can observe the values of your player.currentItem: playerItem.addObserver(self, forKeyPath: “playbackBufferEmpty”, options: .New, context: nil) playerItem.addObserver(self, forKeyPath: “playbackLikelyToKeepUp”, options: .New, context: nil) playerItem.addObserver(self, forKeyPath: “playbackBufferFull”, options: .New, context: nil) then override public func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) { if object is AVPlayerItem { switch keyPath { case “playbackBufferEmpty”: … Read more

Add custom controls to AVPlayer in swift

here I add the points , you need to customize based on your need. Step-1 initially hide your AVPlayer controls, YourAVPlayerViewController.showsPlaybackControls = false Step-2 create the structure like one label for current Duration, One label for overall Duration, one UIbutton for pause and play your current player and one UISlider for seek The video. step-3 … Read more

Avoiding blurriness at start & end of video (even after using setPreferredVideoStabilizationMode:AVCaptureVideoStabilizationModeAuto)?

Video is blurry by its nature. 24 or 30 frames per second video will always have some blur in the shot because that’s the way our eyes are tricked into believing the pictures are actually moving. The longer shutter speed allows the camera to give the impression of motion. Photos use a much shorter shutter … Read more

How to detect when AVPlayer video ends playing?

To get the AVPlayerItemDidPlayToEndTimeNotification your object needs to be an AVPlayerItem. To do so, just use the .currentItem property on your AVPlayer Now you will get a notification once the video ends! See my example: let videoPlayer = AVPlayer(URL: url) NSNotificationCenter.defaultCenter().addObserver(self, selector: “playerDidFinishPlaying:”, name: AVPlayerItemDidPlayToEndTimeNotification, object: videoPlayer.currentItem) func playerDidFinishPlaying(note: NSNotification) { print(“Video Finished”) } Swift … Read more

Pre-buffering for AVQueuePlayer

Ok, I’ve looked over this problem again and written some code to check out AVQueuePlayer. jollyCocoa’s answer pointed me in the right direction by suggesting to observe the status property on AVPlayerItem. However the documentation doesn’t seem to point out that this property (and it’s AVPlayerItemStatusReadyToPlay value in particular) might be related to buffering. However … Read more

capturing self strongly in this block is likely to lead to a retain cycle

The capture of self here is coming in with your implicit property access of self.timerDisp – you can’t refer to self or properties on self from within a block that will be strongly retained by self. You can get around this by creating a weak reference to self before accessing timerDisp inside your block: __weak … Read more

No AVPlayer Delegate? How to track when song finished playing? Objective C iPhone development

Yes, the AVPlayer class does not have a delegate protocol like the AVAudioPlayer. You need to subscribe to notifications on an AVPlayerItem. You can create an AVPlayerItem using the same URL that you would otherwise pass to -initWithURL: on AVPlayer. -(void)startPlaybackForItemWithURL:(NSURL*)url { // First create an AVPlayerItem AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:url]; // Subscribe to … Read more