UINavigationView - Stop a video from playing when back pressed - ios

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.

Related

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.

Make AVPlayerViewController keep playing after done button pressed

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.

Swift - After performing AVAssetExportSession, if I hit the home button and reopen the app, the video disappears from my AVPlayer and it goes black

If I wait a few seconds and close/reopen the app (or scroll the video), the video eventually comes back. I am completely lost as to why the video just disappears and my AVPlayer goes black.
Has anyone encountered this and/or know of a fix?
Edit: I set up the AVPlayer inside an AVPlayerLayer like so: https://codeshare.io/vmBHX

MPMoviePlayerController issue

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.

Resources