Tab Bar Controller STOP Audio Session

Discussion in 'iOS Programming' started by yutamic, Jan 29, 2009.

  1. yutamic macrumors newbie

    Joined:
    Jan 13, 2009
    #1
    I'm trying to figure out a way so I can STOP my audio session
    if a view is changed using the tab bar controller.

    To make things clear, I'm using a Tab Bar Controller to switch views.
    One view is a page where you can play audio (AVAudioPlayer),
    and another view plays movie (MPMoviePlayer).

    The problem is, when the audio is playing on one view,
    and if I try to play the movie on the other view (while the audio is playing),
    somehow the audio session function dies after the movie finishes playing.
    It won't let me play the audio anymore even if I go back to the view that plays Audio.

    So if I can somehow force the audio to stop before the Movie starts playing
    I will be able to save the Audio session from being destroyed.

    Any idea how I should solve this problem??
    I've tried many different approach but couldn't fix this bug...
     
  2. jnic macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #2
    Add an MPMoviePlayerContentPreloadDidFinishNotification to your movie player and use it to turn off your audio player.

    Code:
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourMethodHere:) name:MPMoviePlayerContentPreloadDidFinishNotification object:nil];
     
  3. yutamic thread starter macrumors newbie

    Joined:
    Jan 13, 2009
    #3
    Thank you very much jnic!
    This solved my problem!!
    Now I can finally upload my app without any bug:)
     

Share This Page