The play button is disabled until we have asound file to play. The red recording light goes on when we press the record button.
main.m
SegmentedAppDelegate
View
SegmentedAppDelegate.h
imports
AVFoundation.h
.
The application delegate fulfills three protocols.
The height of the
UISegmentedControl
defaults to 29 pairs of pixels.
But this fact is nowhere in Apple’s documentation
and may therefore change without warning.
See this document.
The
NSNumber
objects in the left column of the
dictionary can be created with Objective-C
literals.
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: @(kAudioFormatAppleIMA4), AVFormatIDKey, @44100.0, AVSampleRateKey, @2, AVNumberOfChannelsKey, nil ];
2013-11-06 20:41:09.805 Segmented[4052:a0b] inputNumberOfChannels == 2 2013-11-06 20:41:09.806 Segmented[4052:a0b] ouputNumberOfChannels == 2 2013-11-06 20:41:09.807 Segmented[4052:a0b] sampleRate == 44100 2013-11-06 20:41:09.808 Segmented[4052:a0b] preferredSampleRate == 0 2013-11-06 20:41:09.808 Segmented[4052:a0b] preferredIOBufferDuration == 0 2013-11-06 20:41:09.809 Segmented[4052:a0b] filename == "/Users/myname/Library/Application Support/iPhone Simulator/7.0.3-64/Applications/FBE0988A-0D72-40FF-9A18-5372706262D2/tmp/recording.caf" 2013-11-06 20:41:09.810 Segmented[4052:a0b] url == "file:///Users/myname/Library/Application%20Support/iPhone%20Simulator/7.0.3-64/Applications/FBE0988A-0D72-40FF-9A18-5372706262D2/tmp/recording.caf" 2013-11-06 20:41:10.069 Segmented[4052:a0b] Application windows are expected to have a root view controller at the end of application launch 2013-11-06 20:41:23.074 Segmented[4052:a0b] audioRecorderDidFinishRecording:successfully: 1 2013-11-06 20:41:27.694 Segmented[4052:a0b] audioPlayerDidFinishPlaying:successfully: 1
usa.png
,canada.png
,mexico.png
In the
initWithFrame:
method of class
View
,
change the array of items to the following.
NSArray *items = [NSArray arrayWithObjects: [UIImage imageNamed: @"usa.png"], [UIImage imageNamed: @"canada.png"], [UIImage imageNamed: @"mexico.png"], nil ];Each
.png
UISegmentedControl
by assigning to its
bounds
property.
#import
s
at the start of
SegmentedAppDelegate.h
.enum { segRecord, segStop, segPlay };which means approximately the same thing as
int segRecord = 0; int segStop = 1; int segPlay = 2;Then in the
switch
statement in the
valueChanged:
SegmentedAppDelegate
,
change
case 0:to
case segRecord:and change
case 1:to
case segStop:etc. Change the
2
to
segPlay
in
audioRecorderDidFinishRecording:successfully:
.
In
View.m
,SegmentedAppDelegate.h
2
in the call to
setEnabled:forSegmentAtIndex:
segPlay
.