From 8c94b9ba5cd35573d4ab02e5ea105ea5112b25be Mon Sep 17 00:00:00 2001 From: Thong Nguyen Date: Fri, 31 Jan 2014 22:45:17 +0000 Subject: [PATCH] Added WAV file test to test app --- ExampleApp/ExampleApp/AppDelegate.m | 11 +++++++- ExampleApp/ExampleApp/AudioPlayerView.h | 4 ++- ExampleApp/ExampleApp/AudioPlayerView.m | 34 ++++++++++++++++--------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/ExampleApp/ExampleApp/AppDelegate.m b/ExampleApp/ExampleApp/AppDelegate.m index 766a627..9f654f1 100644 --- a/ExampleApp/ExampleApp/AppDelegate.m +++ b/ExampleApp/ExampleApp/AppDelegate.m @@ -55,7 +55,7 @@ -(void) audioPlayerViewPlayFromHTTPSelected:(AudioPlayerView*)audioPlayerView { - NSURL* url = [NSURL URLWithString:@"http://my.halloo.com/audio/perfectly.wav"]; + NSURL* url = [NSURL URLWithString:@"http://fs.bloom.fm/oss/audiosamples/sample.mp3"]; STKDataSource* dataSource = [STKAudioPlayer dataSourceFromURL:url]; @@ -82,4 +82,13 @@ [audioPlayer setDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]]; } +-(void) audioPlayerViewQueuePcmWaveFileSelected:(AudioPlayerView*)audioPlayerView +{ + NSURL* url = [NSURL URLWithString:@"http://fs.bloom.fm/oss/audiosamples/perfectly.wav"]; + + STKDataSource* dataSource = [STKAudioPlayer dataSourceFromURL:url]; + + [audioPlayer queueDataSource:dataSource withQueueItemId:[[SampleQueueId alloc] initWithUrl:url andCount:0]]; +} + @end diff --git a/ExampleApp/ExampleApp/AudioPlayerView.h b/ExampleApp/ExampleApp/AudioPlayerView.h index 9f50974..0cbf808 100644 --- a/ExampleApp/ExampleApp/AudioPlayerView.h +++ b/ExampleApp/ExampleApp/AudioPlayerView.h @@ -41,6 +41,7 @@ -(void) audioPlayerViewPlayFromHTTPSelected:(AudioPlayerView*)audioPlayerView; -(void) audioPlayerViewQueueShortFileSelected:(AudioPlayerView*)audioPlayerView; -(void) audioPlayerViewPlayFromLocalFileSelected:(AudioPlayerView*)audioPlayerView; +-(void) audioPlayerViewQueuePcmWaveFileSelected:(AudioPlayerView*)audioPlayerView; @end @interface AudioPlayerView : UIView @@ -52,9 +53,10 @@ UISlider* slider; UISwitch* repeatSwitch; UIButton* playButton; - UIButton* disposeButton; + UIButton* stopButton; UIButton* playFromHTTPButton; UIButton* queueShortFileButton; + UIButton* queuePcmWaveFileFromHTTPButton; UIButton* playFromLocalFileButton; } diff --git a/ExampleApp/ExampleApp/AudioPlayerView.m b/ExampleApp/ExampleApp/AudioPlayerView.m index e844b24..98c40bc 100644 --- a/ExampleApp/ExampleApp/AudioPlayerView.m +++ b/ExampleApp/ExampleApp/AudioPlayerView.m @@ -53,22 +53,27 @@ if (self) { - CGSize size = CGSizeMake(180, 50); + CGSize size = CGSizeMake(220, 50); playFromHTTPButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - playFromHTTPButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.15, size.width, size.height); + playFromHTTPButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.10, size.width, size.height); [playFromHTTPButton addTarget:self action:@selector(playFromHTTPButtonTouched) forControlEvents:UIControlEventTouchUpInside]; [playFromHTTPButton setTitle:@"Play from HTTP" forState:UIControlStateNormal]; playFromLocalFileButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - playFromLocalFileButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.15 + 50, size.width, size.height); + playFromLocalFileButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.10 + 50, size.width, size.height); [playFromLocalFileButton addTarget:self action:@selector(playFromLocalFileButtonTouched) forControlEvents:UIControlEventTouchUpInside]; [playFromLocalFileButton setTitle:@"Play from Local File" forState:UIControlStateNormal]; queueShortFileButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - queueShortFileButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.15 + 100, size.width, size.height); + queueShortFileButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.10 + 100, size.width, size.height); [queueShortFileButton addTarget:self action:@selector(queueShortFileButtonTouched) forControlEvents:UIControlEventTouchUpInside]; [queueShortFileButton setTitle:@"Queue short file" forState:UIControlStateNormal]; + + queuePcmWaveFileFromHTTPButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + queuePcmWaveFileFromHTTPButton.frame = CGRectMake((320 - size.width) / 2, frame.size.height * 0.10 + 150, size.width, size.height); + [queuePcmWaveFileFromHTTPButton addTarget:self action:@selector(queuePcmWaveFileButtonTouched) forControlEvents:UIControlEventTouchUpInside]; + [queuePcmWaveFileFromHTTPButton setTitle:@"Queue PCM/WAVE from HTTP" forState:UIControlStateNormal]; size = CGSizeMake(90, 50); @@ -76,10 +81,10 @@ playButton.frame = CGRectMake(30, 380, size.width, size.height); [playButton addTarget:self action:@selector(playButtonPressed) forControlEvents:UIControlEventTouchUpInside]; - disposeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - disposeButton.frame = CGRectMake((320 - size.width) - 30, 380, size.width, size.height); - [disposeButton addTarget:self action:@selector(disposeButtonPressed) forControlEvents:UIControlEventTouchUpInside]; - [disposeButton setTitle:@"Dispose" forState:UIControlStateNormal]; + stopButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + stopButton.frame = CGRectMake((320 - size.width) - 30, 380, size.width, size.height); + [stopButton addTarget:self action:@selector(stopButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + [stopButton setTitle:@"Stop" forState:UIControlStateNormal]; slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 320, 280, 20)]; slider.continuous = YES; @@ -87,7 +92,7 @@ size = CGSizeMake(80, 50); - repeatSwitch = [[UISwitch alloc] initWithFrame:CGRectMake((320 - size.width) / 2, frame.size.height * 0.15 + 170, size.width, size.height)]; + repeatSwitch = [[UISwitch alloc] initWithFrame:CGRectMake((320 - size.width) / 2, frame.size.height * 0.15 + 180, size.width, size.height)]; label = [[UILabel alloc] initWithFrame:CGRectMake(0, slider.frame.origin.y + slider.frame.size.height, frame.size.width, 50)]; @@ -102,10 +107,11 @@ [self addSubview:playFromHTTPButton]; [self addSubview:playFromLocalFileButton]; [self addSubview:queueShortFileButton]; + [self addSubview:queuePcmWaveFileFromHTTPButton]; [self addSubview:repeatSwitch]; [self addSubview:label]; [self addSubview:statusLabel]; - [self addSubview:disposeButton]; + [self addSubview:stopButton]; [self setupTimer]; [self updateControls]; @@ -179,10 +185,14 @@ [self.delegate audioPlayerViewQueueShortFileSelected:self]; } --(void) disposeButtonPressed +-(void) queuePcmWaveFileButtonTouched +{ + [self.delegate audioPlayerViewQueuePcmWaveFileSelected:self]; +} + +-(void) stopButtonPressed { [audioPlayer stop]; -// audioPlayer = nil; } -(void) playButtonPressed