| Index: webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
|
| diff --git a/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m b/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
|
| index 6f526573e33cde11abceec0dbbea4de40689c611..b2647630e1f2e692ef4f7e334dd8778a23a7df53 100644
|
| --- a/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
|
| +++ b/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
|
| @@ -10,8 +10,6 @@
|
|
|
| #import "ARDMainView.h"
|
|
|
| -#import <AVFoundation/AVFoundation.h>
|
| -
|
| #import "UIImage+ARDUtilities.h"
|
|
|
| // TODO(tkchin): retrieve status bar height dynamically.
|
| @@ -124,24 +122,17 @@ static CGFloat const kAppLabelHeight = 20;
|
| UILabel *_audioOnlyLabel;
|
| UISwitch *_loopbackSwitch;
|
| UILabel *_loopbackLabel;
|
| + UISwitch *_audioConfigDelaySwitch;
|
| + UILabel *_audioConfigDelayLabel;
|
| UIButton *_startCallButton;
|
| UIButton *_audioLoopButton;
|
| - AVAudioPlayer *_audioPlayer;
|
| }
|
|
|
| @synthesize delegate = _delegate;
|
| +@synthesize isAudioLoopPlaying = _isAudioLoopPlaying;
|
|
|
| - (instancetype)initWithFrame:(CGRect)frame {
|
| if (self = [super initWithFrame:frame]) {
|
| - NSString *audioFilePath =
|
| - [[NSBundle mainBundle] pathForResource:@"mozart" ofType:@"mp3"];
|
| - NSURL *audioFileURL = [NSURL URLWithString:audioFilePath];
|
| - _audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL
|
| - error:nil];
|
| - _audioPlayer.numberOfLoops = -1;
|
| - _audioPlayer.volume = 1.0;
|
| - [_audioPlayer prepareToPlay];
|
| -
|
| _appLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
| _appLabel.text = @"AppRTCDemo";
|
| _appLabel.font = [UIFont fontWithName:@"Roboto" size:34];
|
| @@ -184,6 +175,18 @@ static CGFloat const kAppLabelHeight = 20;
|
| [_loopbackLabel sizeToFit];
|
| [self addSubview:_loopbackLabel];
|
|
|
| + _audioConfigDelaySwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
|
| + [_audioConfigDelaySwitch sizeToFit];
|
| + _audioConfigDelaySwitch.on = YES;
|
| + [self addSubview:_audioConfigDelaySwitch];
|
| +
|
| + _audioConfigDelayLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
| + _audioConfigDelayLabel.text = @"Delay audio config";
|
| + _audioConfigDelayLabel.font = controlFont;
|
| + _audioConfigDelayLabel.textColor = controlFontColor;
|
| + [_audioConfigDelayLabel sizeToFit];
|
| + [self addSubview:_audioConfigDelayLabel];
|
| +
|
| _startCallButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
| _startCallButton.backgroundColor = [UIColor blueColor];
|
| _startCallButton.layer.cornerRadius = 10;
|
| @@ -223,6 +226,14 @@ static CGFloat const kAppLabelHeight = 20;
|
| return self;
|
| }
|
|
|
| +- (void)setIsAudioLoopPlaying:(BOOL)isAudioLoopPlaying {
|
| + if (_isAudioLoopPlaying == isAudioLoopPlaying) {
|
| + return;
|
| + }
|
| + _isAudioLoopPlaying = isAudioLoopPlaying;
|
| + [self updateAudioLoopButton];
|
| +}
|
| +
|
| - (void)layoutSubviews {
|
| CGRect bounds = self.bounds;
|
| CGFloat roomTextWidth = bounds.size.width - 2 * kRoomTextFieldMargin;
|
| @@ -264,8 +275,22 @@ static CGFloat const kAppLabelHeight = 20;
|
| _loopbackLabel.center = CGPointMake(loopbackModeLabelCenterX,
|
| CGRectGetMidY(loopbackModeRect));
|
|
|
| + CGFloat audioConfigDelayTop =
|
| + CGRectGetMaxY(_loopbackSwitch.frame) + kCallControlMargin;
|
| + CGRect audioConfigDelayRect =
|
| + CGRectMake(kCallControlMargin * 3,
|
| + audioConfigDelayTop,
|
| + _audioConfigDelaySwitch.frame.size.width,
|
| + _audioConfigDelaySwitch.frame.size.height);
|
| + _audioConfigDelaySwitch.frame = audioConfigDelayRect;
|
| + CGFloat audioConfigDelayLabelCenterX = CGRectGetMaxX(audioConfigDelayRect) +
|
| + kCallControlMargin + _audioConfigDelayLabel.frame.size.width / 2;
|
| + _audioConfigDelayLabel.center =
|
| + CGPointMake(audioConfigDelayLabelCenterX,
|
| + CGRectGetMidY(audioConfigDelayRect));
|
| +
|
| CGFloat audioLoopTop =
|
| - CGRectGetMaxY(loopbackModeRect) + kCallControlMargin * 3;
|
| + CGRectGetMaxY(audioConfigDelayRect) + kCallControlMargin * 3;
|
| _audioLoopButton.frame = CGRectMake(kCallControlMargin,
|
| audioLoopTop,
|
| _audioLoopButton.frame.size.width,
|
| @@ -282,7 +307,7 @@ static CGFloat const kAppLabelHeight = 20;
|
| #pragma mark - Private
|
|
|
| - (void)updateAudioLoopButton {
|
| - if (_audioPlayer.playing) {
|
| + if (_isAudioLoopPlaying) {
|
| _audioLoopButton.backgroundColor = [UIColor redColor];
|
| [_audioLoopButton setTitle:@"Stop sound"
|
| forState:UIControlStateNormal];
|
| @@ -296,12 +321,7 @@ static CGFloat const kAppLabelHeight = 20;
|
| }
|
|
|
| - (void)onToggleAudioLoop:(id)sender {
|
| - if (_audioPlayer.playing) {
|
| - [_audioPlayer stop];
|
| - } else {
|
| - [_audioPlayer play];
|
| - }
|
| - [self updateAudioLoopButton];
|
| + [_delegate mainViewDidToggleAudioLoop:self];
|
| }
|
|
|
| - (void)onStartCall:(id)sender {
|
| @@ -312,9 +332,10 @@ static CGFloat const kAppLabelHeight = 20;
|
| }
|
| room = [room stringByReplacingOccurrencesOfString:@"-" withString:@""];
|
| [_delegate mainView:self
|
| - didInputRoom:room
|
| - isLoopback:_loopbackSwitch.isOn
|
| - isAudioOnly:_audioOnlySwitch.isOn];
|
| + didInputRoom:room
|
| + isLoopback:_loopbackSwitch.isOn
|
| + isAudioOnly:_audioOnlySwitch.isOn
|
| + shouldDelayAudioConfig:_audioConfigDelaySwitch.isOn];
|
| }
|
|
|
| @end
|
|
|