forked from mirrors/linphone-iphone
fix endless of record
This commit is contained in:
parent
8b937f5749
commit
045365958f
3 changed files with 17 additions and 7 deletions
|
|
@ -17,6 +17,7 @@
|
|||
+ (id)audioPlayerWithFilePath:(NSString *)filePath;
|
||||
- (void)close;
|
||||
- (BOOL)isOpened;
|
||||
- (BOOL)isCreated;
|
||||
- (void)open;
|
||||
- (void)pause;
|
||||
- (void)setFile:(NSString *)fileName;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
- (void)close {
|
||||
if (player) {
|
||||
linphone_player_close(player);
|
||||
linphone_player_unref(player);
|
||||
player = NULL;
|
||||
}
|
||||
|
|
@ -60,6 +61,10 @@
|
|||
[_stopButton setImage:[UIImage imageFromSystemBarButton:UIBarButtonSystemItemRefresh:[UIColor blackColor]] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[self close];
|
||||
}
|
||||
|
||||
- (void)open {
|
||||
linphone_player_open(player, file.UTF8String);
|
||||
duration = linphone_player_get_duration(player);
|
||||
|
|
@ -76,8 +81,12 @@
|
|||
return player && linphone_player_get_state(player) != LinphonePlayerClosed;
|
||||
}
|
||||
|
||||
- (BOOL)isCreated {
|
||||
return player;
|
||||
}
|
||||
|
||||
- (void)setFile:(NSString *)fileName {
|
||||
linphone_player_close(player);
|
||||
if (player) linphone_player_close(player);
|
||||
file = fileName;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,12 +96,12 @@ static UILinphoneAudioPlayer *player;
|
|||
if (!selected) {
|
||||
return;
|
||||
}
|
||||
if (!player)
|
||||
player = [UILinphoneAudioPlayer audioPlayerWithFilePath:[self recording]];
|
||||
else
|
||||
[player setFile:[self recording]];
|
||||
if ([player isOpened])
|
||||
[player close];
|
||||
if (player && [player isCreated]) {
|
||||
[player close];
|
||||
}
|
||||
|
||||
player = [UILinphoneAudioPlayer audioPlayerWithFilePath:[self recording]];
|
||||
|
||||
[player.view removeFromSuperview];
|
||||
[self addSubview:player.view];
|
||||
[self bringSubviewToFront:player.view];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue