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
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.
Related
I have an issue where when user is playing a video , while video is being player, he uses siri to search for a different movie, which will load its corresponding movie details page and then select to play that movie, which deeplinks to your app which is playing a movie, when i play a new selected movie and dismiss avplayer and avplayercontroller, audio from previous video still continues to play. somehow avplayer is not cleared although i clear all subviews from window and initialize its super view controller class again. I am cluless what can i do erase older instance of avplayer. Let me know if anyone has any suggestions or faced similar issue.
A few suggestions:
Are you subclassing AVPlayerViewController? If so, that's a bad idea. The API docs specifically say not to do that.
Add a deinit function. If it's not being called when the old AVPlayer is dismissed, you know you have a retention problem. This is often caused by registering for notifications or boundary time observers.
If you view controller has a reference to the AVPlayer object, you might try overriding the viewDidDisappear function to call player.pause() and then setting the player reference first to a new instance of AVPlayer() then to nil. Not sure why this helps, but sometimes it does.
Definitely implement #2 above. If deinit is not getting called, you most certainly have an issue.
In my iOS app, I'm using AVFoundation's AVComposition to create a video, with multiple audio tracks. I am trying to let the user see the volume/power-level for each audio-track. I've successfully implemented this for one track, but as soon as I try to use a second MTAudioProcessingTap, it fails with OSError -12780. In fact, if I use a processingTap and then go 'back' - deallocating the entire view controller, and re-opening that particular window, it won't even attach the processingTap again, even if the first AVPlayer playing the composition has been deallocated. To solve this, I found out from searching that I have to manually release it and clearing out the audioMix for the player, but that's not my problem now. Now, I can't clear out the other processingTap, I need them both!
I'm not completely sure what the MTAudioProcessingTap actually is, as it is the single least documented piece of code ever to come out of the Apple dev-team, by far. I've watched the WWDC, and gone through the iPad-sample-project they have made, but I can't figure out how to have two taps running.
I figured I might not actually need two taps, but maybe use one to handle more than one audioTrack, however if I somehow manage to use the same tap for two AudioTracks, I wouldn't know how to tell the taps apart in the static callbacks. Is there perhaps another way to monitor audio-levels from an AVComposition playing in an AVPlayer, or is there a way like this?
As stated in the subject, how I am going to keep the audio playing inside the UIWebView after popping the view. As what I have read and done before, the audio will be playing for good 3 seconds and stop after that. Thank you in advance.
I think, You can't do it. Coz your webView will be removed after popping the controller
I have used AVQueuePlayer several times and the default behaviour is to continue playing when you change view, but in my case when I navigate to the previous view where I came from by segue, the player stops. I put a breakpoint after dealloc to see if the AVQueuePlayer is released and from what I can see it's not deallocated (I have a strong reference to it using property). Please help!!!
I am streaming audio using several links from a server, not playing local files. I created the url, used the url to make AVPlayerItems, and added the player items into array, I used this array to initiate the AVQueuePlayer. I used GCD to make sure my array is completely ready before I play the AVQueuePlayer.
As soon I click on back button it stops. I am pulling out my hair
Create a singleton class that provides an interface to the AVQueuePlayer. That way you will be sure that it's alive even when you pop your view controllers.
I know there have been a few hints on Stackoverflow about this issue but I haven't found a very satisfying answer to my problem.
I want to completely remove a video playing with AVPlayer in an AVPlayerLayer class from memory. I have read your are actually not allowed to call dealloc of the class containing the AVPlayerLayer. But even when I do so, the video remains in memory (cfr the sound does not stop playing).
Some people hint that you should pause the player, or just load in a new video, but I want it gone...
I need this because when rotating the device, I want the video kicked out of memory and a new video loaded in for the new orientation. I need to destroy the video completely because the parent view it is in also needs to be destroyed.
This is the structure I have
UIView
-> UIScrollView
-> UIviewWithPlayer
->AVPlayerLayer
In UIscrollView I call release and removefromsuperview on UIViewWithPlayer. In UIviewWithPlayer I call release and removefromsuperview on AVPlayerLayer. But that does not seem to work.
Thank you very much in advance for your help.