Shahbaz Saleem
Shahbaz Saleem

Reputation: 327

IOS Detect call interruption while streaming video

I'm streaming video using AVPlayer and i want to pause the video when GSM call comes and resume when the call will end and control is back to my app. How can i achieve this?

Upvotes: 1

Views: 150

Answers (1)

Shahbaz Saleem
Shahbaz Saleem

Reputation: 327

I figured it out, i did it by using AVAudioSessionInterruptionNotification. Below is code snippet

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(routeInterrypt:) name:AVAudioSessionInterruptionNotification object:nil];


-(void)routeInterrypt:(NSNotification *)notification {
    NSDictionary *dic = notification.userInfo;
    int changeReason= [dic[AVAudioSessionRouteChangeReasonKey] intValue];
    if (changeReason == AVAudioSessionRouteChangeReasonUnknown) {
        if (_state == TYVideoPlayerStateContentPlaying || _state == TYVideoPlayerStateBuffering) {
            [self pauseContent];
            return;
        }
    } }

Upvotes: 1

Related Questions