Make AVPlayerViewController keep playing after done button pressed - ios

I have an instance of AVPlayerViewController playing a live broadcast content that I am adding as a subview to my viewController's view.
After switching the AVPlayerViewController to fullscreen mode and tapping Done button to exit fullscreen the player stops playing.
Is there any way to keep the player playing after done button action?

This is not possible with AVPlayerViewController. But when using fullscreen button the player keeps playing. For my case I ended up by creating a custom player controller with an AVPlayer instance.

Related

Disabled play, next track, previous track buttons on now playing info on notification screen

Play, next track, previous track buttons gets disabled when I start play a music track after AVPlayerViewController finished showing video.
Reproduction steps:
start music track on AVPlayer
pause music track on AVPlayer
start showing video on AVPlayerViewController with different AVPlayer
close AVPlayerViewController
start (unpause) music track on AVPlayer
show notification screen
And I see that button are disabled.
I want to have enabled buttons rather than disabled. What do I do wrong?
After video is finished you should update nowPlayingInfo in MPNowPlayingInfoCenter

Transition avplayer to fullscreen from embedded view

I am currently displaying a video embedded in a view. On tap of this video I need to present it in full screen just like how App Store does it.
Right now I am using AVPlayer to embed in the view with a AVPlayerLayer. When I detect a tap on this embedded player, I am creating a AVPlayerViewController and setting its player object with the player currently embedded, but still I can notice a delay of 3~4 seconds until the player in fullscreen starts playing. How can I make this transition smooth ?

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.

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.

Previous frame is shown when I set the paused time and call play on MPMoviePlayerController

I am using MPMoviePlayerController to play the movie in iPhone. When I switch to some other UIViewController I pause the movie. When I come back to MPMoviePlayerController, user should be able to resume from the point where it was paused.
When I switch to some other UIViewController:
Pause the movie
Cache the movie time when it was paused.
Remove the view of MPMoviePlayerController from its superview due to some flickering issue.
When I come back,
a) create and add the view of MPMoviePlayerController to the superview
b) Set the cached time to the MPMoviePlayerController
c) Call play on MPMoviePlayerController.
Sometimes, the previous frame (which is far by the frame where it was paused by observable amount) is shown when I call play.
How do I solve this?

Resources