Mytheral
Mytheral

Reputation: 3959

iOS - Stopping a Video on Navigation Change

So here is my dilemma, I have a navigation controller that controls three views. The first view has audio on it, the second view image sequences/videos and the third view will have audio.

How can I make sure that all of those things are ended (or just end them) when someone clicks the "Back" button to go to a lower numbered view?

Upvotes: 0

Views: 436

Answers (3)

bealex
bealex

Reputation: 10014

Look at UINavigationControllerDelegate. It has needed methods.

Upvotes: 0

Mark Adams
Mark Adams

Reputation: 30846

Make yourself the delegate of the UINavigationController and implement this:

- (void)navigationController:(UINavigationController *)navController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // Pseudo Code Here
    [audio stopPlaying];
}

Upvotes: 1

Bogatyr
Bogatyr

Reputation: 19333

media player classes, like audio and video, usually have "stop" methods that will do the trick. You can hook in to the viewWill/Did/Appear/Disapper methods on UIViewController to know when a view is/did become(ing) visible/invisible and stop the media playback at that time. I also like to put put "stop" method calls to media players in viewWillUnload and dealloc.

Upvotes: 1

Related Questions