MPMoviePlayerController issue - ipad

In our iPad app, a video stream is playing in a player view. The player view has a button to go to a new view (I push the new view in the navigation controller when user clicks this button). The new view has a back button to go back to the player view.
The requirement is that the video should continue to play even though the user clicks the button to push the new view and now the new view is visible to the user to tell the user the video is still playing.
This works fine. I can hear the audio when I go to the new view and I am not releasing my player. However, if I stay on the new view for about 2 minutes and then hit the back button to go to the player view, the audio continues correctly. But the video just fast forwards the frames that have gone by in the 2 minutes and then comes to the current video frame.
Can anyone please suggest why this could be happening?

You can try addSubView rather than pushing a new view when user clicks on button to go on new view.
I solved my similar problem by this way.

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.

UIViewController's view has weird 20px

Hello Guys I am facing a wierd behaviour in my app the case is like this :
From view controller(A) present another view controller (B) which has a UIWebView that will open an URL, but sometime the URL is Video link,
Sot he video starts playing in full screen and when finish and tap on Done (Dismiss Video player) and then dismiss the Controller (B) a weird 20px appeared at the bottom of view controller(A) and the whole app will lose the 20px in all screens.
Any one has idea for what is happening, I am certain sure that it caused by playing video through UIWebView
Update 1 :
I just figured out that this could be related to the iOS itself when playing videos whether from video file or from video url (since both will be played using the same player).
My experiment was on Facebook app when I post the same links used in my app inside Facebook app then try to play the videos from the links and the behaviour showed !
I wish if could someone help to confirm if playing videos causing problems on the UI.

Change the view that a video is playing on

In my app the user can play a video and leave the screen and it will continue to play in the background (just the audio). They can then return to continue to watch the video. This means that the view the video is in is destroyed and then recreated at a later point. Whenever the view is recreated and the player is set on it's AVPlayerLayer there is a noticeable lag in the video and more importantly the audio.
Does anyone know how to eliminate this lag?
The key to making this work without any lag / delay in the audio or video is to store the view with the AVPlayerLayer outside of the view. When reloading the controller, instead of creating a new view and assigning its player to the same player, simply attach the old view to the new view controller's view.
The view stays in memory as long as the video is still playing, that way a new AVPlayerLayer is not created and assigned to. It is the reassigning that causes the lag.

MPMoviePlayerController dismissing full screen mode not working in iOS 6

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.

UINavigationView - Stop a video from playing when back pressed

I have a UINavigationView where I push on a ViewController containing a WebView with a YouTube video. When the video is run, then the back button is pressed on the UINavigationView, the sound of the video continues to play.
How do I stop the video playing in the WebView when it is no longer visible?
Make sure your web view is getting deallocated when the view controller goes away.

Resources