1

I'm using AVPlayer to stream an audio file for my project. The problem I'm facing is the audio file plays after getting pop from the AudioPlayerVC. Everything is okay when the audio plays on the AudioPlayerVC. It stops, plays and pauses too on AudioPlayerVC. But on the buffering time when I return back, it plays after some sec. I can listen to sound but cannot stop or do anything else.

- (IBAction)backAction:(id)sender { 
    if (_audioToPlay.playing == YES) {
        [_audioToPlay stop];
    } else if (_audioToPlay.playing == NO || _audioToPlay.volume == 1.0 ) {
        _audioToPlay.volume = 0.0;
        [_audioToPlay stop]; 
    }
    [self.navigationController popViewControllerAnimated:YES];
}
Jeremy W
  • 1,889
  • 6
  • 29
  • 37
Ankit Kumar
  • 280
  • 2
  • 17
  • can u post some code for reference. – spider1983 Jan 29 '15 at 10:27
  • - (IBAction)backAction:(id)sender { if (_audioToPlay.playing == YES) { [_audioToPlay stop]; } else if (_audioToPlay.playing == NO || _audioToPlay.volume == 1.0 ) { _audioToPlay.volume = 0.0; [_audioToPlay stop]; } [self.navigationController popViewControllerAnimated:YES]; } – Ankit Kumar Jan 29 '15 at 10:36
  • if you have defined your audio player as a property remove it and define it as simple object and then try your above code. – spider1983 Jan 29 '15 at 12:17

1 Answers1

0

If below is not working then Refer avplayer-continues-to-play-after-viewcontroller-is-removed-from-navigationcontroller

You can do is firstly pause player :

[yourAVPlayer pause];

Then pop to Parent View Controller

[self.navigationController  popViewControllerAnimated:YES];
Community
  • 1
  • 1
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • I'm doing it as - [myAVPlayer stop]; Then pop to Parent View Controller [self.navigationController popViewControllerAnimated:YES]; is it a wrong way I'm using – Ankit Kumar Jan 29 '15 at 10:17