iphone - Do something when audio stops -
im wondering of how make app aware of when audio stops. have 30 minute audio recorded thats triggered when hit play button. play button changed pause button. pause button switch play button when audio complete. using avaudioplayer. how do this? thanks!
the avaudioplayerdelegate contains method called audioplayerdidfinishplaying:successfully:
. override method , put play/pause button login in there.
something this:
in .h
#import <uikit/uikit.h> #import "avfoundation/avaudioplayer.h" @interface viewcontroller : uiviewcontroller<avaudioplayerdelegate> @end
in .m
@implementation viewcontroller{ avaudioplayer *_player; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. _player.delegate = self; } -(void)audioplayerdidfinishplaying:(avaudioplayer *)player successfully:(bool)flag{ //show play button } @end
more info on avaudioplayerdelegate here
Comments
Post a Comment