Video link in UIWebView Glitch

363 views Asked by At

I have a UIWebView in my app linked to the url of a blog page. Whenever I click on a video embedded in the blog page (not embedded in the app on my end) it opens fine to the media player and plays and pauses just fine. This is something that I did NOT initialize. It seems iOS just picks it up.

However my problem is that when you hit the forward button, the video finishes or you hit the done button it closes the media player and sends me back to my initial view controller (NOT the view controller that initiated the media player), shifts the image up and leaves a white area the size of the status bar at the bottom and stops you from navigating through the app.

I can't figure out how to fix this. I have tried adding:

[[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector(moviePlayBackDidFinish:) 
 name:MPMoviePlayerPlaybackDidFinishNotification 
 object:moviePlayer];

to the viewdidload method.

Am I placing this in the wrong section? Is there more I should be doing? Is there something else that should be used as the object besides moviePlayer?

I still think it's weird that the app would start playing video without any programming for a media player but not terminate the video properly since it initialized it in the first place.

This is the last thing holding up my app. Please if anyone can help it would be greatly appreciated.

1

There are 1 answers

0
johnnelm9r On BEST ANSWER

Ok so after countless hours of research I found out that this comes from having a modal transition from my initial view controller to my tabbarcontroller. Apparently the default uiwebview media player doesn't handle two modal views all that well. After embedding my initial view controller in a navigation controller I am able to push from the initial view controller to the tabbarcontroller with no problem. This also eliminated the problem with the uiwebview media player.Hopefully this helps someone else as well!

Just to clarify I DID remove the line of code from my original post as it was unnecessary.

Thanks to favo for cleaning up my original post! :)