I am implementing a video app, that lists video and able to stream or watch local videos. If I try to watch videos with my player that inherits from AVPlayer, a lot of threads initated, after 15-20 times, the system does not alloc the AVPlayer well and, even if I do not get any error, the player view is blank and nothing happening...I need to kill app to restore.
How to deal with it?
Thanks in advance
An object that models the timing and presentation state of an asset that a player object presents. An AVPlayerItem stores a reference to an AVAsset object, which represents the media to be played.
AVPlayer — An AVPlayer is a controller object used to manage the playback and timing of a media asset. You can use an AVPlayer to play local and remote file-based media, such as QuickTime movies and MP3 audio files, as well as audiovisual media served using HTTP Live Streaming. Line 1 — AVAsset object is created using the video URL.
A class that encapsulates the presentation state of an AVAsset being played by a AVPlayer object. The AVPlayerItem holds the dynamic presentation state of an AVAsset being played by a AVPlayer. Creates a new T:AVFoundation.AVAVPlayerItem suitable for playing asset.
Alternatively, AVPlayerItem can automatically load the needed asset data for you by passing the desired set of keys to its init (asset:automaticallyLoadedAssetKeys:) initializer. When the player item is ready to play, those asset properties will have been loaded and are ready for use. AVPlayerItem is a dynamic object.
I had the same issue, in my case the AVPlayerLayer didn’t get DE allocated successfully because somehow a custom label grabbed the strong reference of controller and the controller did not get DE allocated. Implement
deinit {
}
in your controller and check this called or not. If not you have the solution. I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With