MPMoviePlayerController dismissing full screen mode not working in iOS 6 - ios

The MPMoviePlayerController working fine in iPad with iOS 5, initially the video starts by adding MPMoviePlayerController to subview of self at certain frame .Pressing full screen button on MPMoviePlayerController embedded controls displaying the movie in full screen,again tapping the button will bring the video back to the initial frame in iOS 5. But in iOS 6, the when I press full screen button to bring the video to initial frame, the video just gone out of screen. Looks like Apple has made some undocumented change to MPMoviePlayer class that is causing this weird behaviour. Anyone having the fix for this?

I have fixed this issue myself, in iOS 6, apple has made some undocumented changes to MPMoviePLayerController class, when you tap on full screen button, the viewWillDisappear and viewDidDisAppear gets called for both the controller launching MPMoviePLayerController and its ParentController.
In My Project (a pdf reader), I have a very complex view hierarchy, adding a reader in view Controller, then adding the readerPageContents buttons(image Gallery, video, link) to reader page and then playing video on video button tap.So it was calling the ViewWillDisappear and ViewDidDisappear when launching the video in full screen, and when when I press toggle screen button to bring the video to initial frame, the ViewWillAppear and ViewDidAppear of both controllers called again and I was creating the pdf page again in parent's controller viewDidAppear which was removing the video.
So easier fix it to avoid ViewDidDisappear and ViewWillDisappear gets called by setting some BOOL.

Related

Play the video in two view controllers from where the previous video stopped

I have a table view controller that has a video view in each cell.
Each cell has a play button, slider and a full screen button.
I have implemented logic for playing , pausing and seeking the video using AVPlayerLayer.
When I click on the full screen button I am moving to another view controller where I will play the video in full screen in portrait and landscape mode
When I move to the full screen controller I want the video to play from where it was playing in the previous view controller.
And when I move back to the previous view controller the video should play from where it played in the full screen controller.
How can I achieve this? Any help will be appreciated. Thank you
I have implemented same for an audio player which has a mini player and tapping on it will open in full screen.
I have detached audio player from UI. Created singleton class of player which will update UI. So there will be only one instance of player which will update multiple UI in sync.
You can implement same logic for your player.

Stop Screen From AutoRotating, but Keep UIWebView Rotation

I have a UIWebView in my viewcontroller that is embedding a YouTube video and when the user clicks it, it plays the video. I want the webview to be able to rotate, but not the viewcontroller that it's being held on. Are there any solutions out there for this problem? This is an iOS6 and above supported application.
In your shouldAutorotateToInterfaceOrientation method, change the UIWebView to the new orientation, then return NO.
This way the view controller will stay the way it is, but you can do whatever you need to do to the UIWebView to make it display correctly in the new orientation.

how to fix youtube video in uiwebview from playing behind parent view controller

I have implemented TTPhotoViewController in my app and it is working fine. However, it seems to have broken the landscape orientation on the the only view controller that rotates in my tabbarcontroller (subclassed). I have also returned NO in - (BOOL)shouldAutorotateToInterfaceOrientation: in my subclassed TTphotoviewcontroller and TTThumbviewcontrollers to stop landscape orientation of the photo gallery.
The view controller that previously was able to orientate to landscape plays youtube videos. The view controller loads a list of videos (youtube mobile page) but now when you select a video to play the file plays in the iOS movieplayer in landscape (which is a good thing) but BEHIND the parent view controller which remains in portrait.
I have removed the code to force the video view controller to orientate to landscape and the behaviour persists, which makes me think it is something to do with a file in the Three20 library.
Any ideas?

How to prevent my MPMoviePlayerController from getting black when back from a webView containing a YouTube Video - iOS

Here is the context :
NavigationController -> FirstViewController -> SecondViewController
FirstViewController display a MPMoviePlayerController in embedded mode, and buttons to go to SecondViewController. This MPMoviePlayerController is reading a local .m4v file.
SecondViewController display a UIWebView with web pages containing YouTube videos.
Here are the steps :
the user read the video on FirstViewController (works fine)
the user press one of the buttons to go to SecondViewController
the user press one of the youtube video, that will play in embedded mode in the webView (works fine too)
the user press the Back button in NavigationItem
The problem appear at this particular moment :
When the user come back from SecondViewController, the MPMoviePlayerController is black.
I tried using prepareToPlay on the moviePlayer in viewWillAppear and/or viewDidAppear. In both cases, I got a good result for half a sec and then the MoviePlayer view is turned to black again.
I think that when the viewDidUnload is called in the SecondViewController, something happen that put a brief access to the web embbedded MoviePlayer.
Any idea about how to solve the problem ?
Note : this only appear on a device because videos don't appear on UIWebView in simulator. I tried to reproduce it with another MPMoviePlayerController in the second view but putting a prepareToPlay in the viewDidAppear solved it...
Note 2: this problem only appear on iPad. I tried to reproduce it on iPhone but the youtube player won't play video in embedded mode on iPhone...
There should be no movie player code. Just put your video url on your web view code it shall work fine.

iPad embedded YouTube video player stays in fullscreen after stopping it programatically

I have a UIWebView that loads a YouTube video.
The problem is, that if the video is playing in full screen and I reload the web view to "about:blank" to stop the video, the video player remains as the top view in the window's view hierarchy and blocks everything.
Only the black video player remains visible.
Has someone encountered this issue?
Thanks.
I have the same problem.
Using the old embed code ( http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application) causes this problem for me. Similarly, the video does not rotate into landscape mode.
I've switched over to the beta code at http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html. Seems to work.
The inability to switch to landscape during playback is still there though.

Resources