ios - AVPlayer interruptions handling -
i need handle avplayer interruptions incoming calls , headphones unplugging.
so i'm trying use following code:
viewcontroller.h
@interface viewcontroller : uiviewcontroller <uiwebviewdelegate, avaudiosessiondelegate>
viewcontroller.m
- (void)viewdidload { [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayback error:nil]; [[avaudiosession sharedinstance] setactive:yes error:nil]; [[avaudiosession sharedinstance] setdelegate:self]; } - (void)begininterruption { } - (void)endinterruption { } - (void)endinterruptionwithflags:(nsuinteger)flags { }
begininterruption , endinterruptionwithflags: called when incoming call received, not when headphones unplugged.
i can use callback instead of delegate don't want duplicate code.
Comments
Post a Comment