Impossible to stop AVPlayer
From this post I found the best solution to completely stop AVPlayer before you leave or start a new player: videoPlayer.replaceCurrentItemWithPlayerItem(nil) [Update] For SWIFT 3: player.replaceCurrentItem(with: nil)
From this post I found the best solution to completely stop AVPlayer before you leave or start a new player: videoPlayer.replaceCurrentItemWithPlayerItem(nil) [Update] For SWIFT 3: player.replaceCurrentItem(with: nil)
If you do some basic level of profiling, I think you can narrow down the problem. For me, I had a similar issue where replaceCurrentItemWithPlayerItem was blocking the UI thread. I resolved it by examining my code to find out which line was taking time. For me the AVAsset loading was taking time. So I … Read more
This seems to be a problem with trying to play videos on the simulator. I’ve had this problem for months now, and just ran into it again today when I was trying to play video on my simulator. The solution, while not great, is to use an actual device instead of the simulator for testing … Read more
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
This is an error when system tries to access the keychain item and which is not found. Refer Link for more information @constant errSecItemNotFound The item cannot be found. errSecItemNotFound = -25300 So internally AVFoundation, Speech To Text like frameworks are using Keychain itself. If you are getting this issue in your own codes: Refer: … Read more
Yes, it stops because the buffer is empty so it has to wait to load more video. After that you have to manually ask for start again. To solve the problem I followed these steps: 1) Detection: To detect when the player has stopped I use the KVO with the rate property of the value: … Read more
Check your phone is silent mode or not. If it is silent try add code below to viewDidLoad: Swift 2.3 try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, withOptions: []) Swift 3 try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: []) Swift 4.2 try! AVAudioSession.sharedInstance().setCategory(.playback, options: []) Or just try! AVAudioSession.sharedInstance().setCategory(.playback)
I’ve the solution! Set only the MPMediaItemPropertyPlaybackDuration 1 – When you start the track, set the property with the total duration of the track: MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter]; NSDictionary *songInfo = @{ MPMediaItemPropertyTitle: title, MPMediaItemPropertyArtist: artist MPMediaItemPropertyPlaybackDuration : [NSNumber numberWithFloat:length] }; center.nowPlayingInfo = songInfo; 2 – when you pause the track… do nothing. 3 … Read more
So the project is now live in the App Store and it is time to come back to this thread and share my findings and reveal what I ended up doing. What did not work The first option where I used on big AVComposition with all the videos in it was not good enough since … Read more
I know you don’t want to use the AVAssetImageGenerator but I’ve also researched this extensively and I believe the only solution currently is using the AVAssetImageGenerator. It’s not that difficult as you say to get the right coordinate because you should be able to get the current time of your player. In my App the … Read more