Keep UIWebView play audio after PopViewController - ios

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

Related

tvOS issue with Siri search deeplinking integration

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.

Is there a way to prevent AVPlayerViewController from updating the lock screen via MPNowPlayingInfoCenter?

here is my problem:
I've got an app playing audio files, updating the lockscreen info via MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo, and this part is working fine.
But in an other view, i'm playing a video with AVPlayerViewController and AVPlayer, and when the video starts playing, it's updating the lock screen automatically, with nothing except the video duration.
I didn't find anything about this behaviour in Apple's documentation, I can't find a way to disable it.
So far, I've tried calling UIApplication.sharedApplication().endReceivingRemoteControlEvents() before the video starts playing, and beginReceivingRemoteControlEvents() after. It doesn't work.
Does anyone know a way to prevent this?
Starting with iOS 10 there is a BOOL property in AVPlayerViewController called updatesNowPlayingInfoCenter, that has the default value: YES. Just change it to NO:
//playerController is an instance of AVPlayerViewController
if ([self.playerController respondsToSelector:#selector(setUpdatesNowPlayingInfoCenter:)])
{
self.playerController.updatesNowPlayingInfoCenter = NO;
}

How to properly delete/release AVPlayer/AVPlayerItem?

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.

Transitioning to background, AVPlayer Video has small audio gap

I have followed the many helpful previous questions to get my AVPlayer successfully streaming video when my app goes to the background. There are two methods described on Apple's QA1668 and they both work for my stream urls.
The problem is that there is a noticeable audio gap during the transition that is identical for both methods. On my iPhone 6 in release mode I would say the gap is less than 0.5 seconds, which may not seem terrible but if I'm playing something like a music video this is very distracting.
After more testing it looks like this gap actually occurs when I remove the AVPlayerLayer (or, if I am using the other method, when I disable the AVMediaCharacteristicVisual tracks) as I have determined it will still happen if I hook those actions up to a button rather than the backgrounding state.
My guess is that is has something to do with the audio re-syncing to the new video state of the AVPlayer but really I have no clue. Any help would be greatly appreciated!

AVQueuePlayer stops playing when I navigate to previous view

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.

Resources