Search code examples
iosswiftvideouitabbarcontrolleruitabbar

Video in original VC continues playing after switching to a different tab in tab bar


I currently have a view controller that is playing a video. When i click a tab in in the tab bar, I switch to a new VC but the audio from the original video is still playing. Is there any way to stop the audio?

Thank You!


Solution


  • Call

    playerLayer.pause()
    

    in viewWillDisappear or viewDidDisappear in the first viewController.