Cocoa API解説(macOS/iOS)

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。

目次

AVFoundationフレームワーク

フレームワークの説明

iPhoneでのサウンドの再生、録音のフレームワークです。

お菓子駄菓子15点詰合せセット

お菓子駄菓子15点詰合せセット


AVAudioPlayer.h
AVAudioRecorder.h
AVAudioSession.h
AVAudioSettings.h
AVFoundation.h

Class References


+ (id)sharedInstance;

@property(assign) id delegate;

- (BOOL)setActive:(BOOL)beActive error:(NSError**)outError;

- (BOOL)setCategory:(NSString*)theCategory error:(NSError**)outError;
- (BOOL)setPreferredHardwareSampleRate:(double)sampleRate error:(NSError**)outError;
- (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration error:(NSError**)outError;

@property(readonly) NSString* category;
@property(readonly) double preferredHardwareSampleRate;
@property(readonly) NSTimeInterval preferredIOBufferDuration;

@property(readonly) BOOL inputIsAvailable;
@property(readonly) double currentHardwareSampleRate;
@property(readonly) NSInteger currentHardwareInputNumberOfChannels;
@property(readonly) NSInteger currentHardwareOutputNumberOfChannels;

@end

Protocol References

- (void)beginInterruption;
- (void)endInterruption;

- (void)categoryChanged:(NSString*)category;

- (void)inputIsAvailableChanged:(BOOL)isInputAvailable;

- (void)currentHardwareSampleRateChanged:(double)sampleRate;
- (void)currentHardwareInputNumberOfChannelsChanged:(NSInteger)numberOfChannels;
- (void)currentHardwareOutputNumberOfChannelsChanged:(NSInteger)numberOfChannels;

- (id)initWithURL:(NSURL *)url settings:(NSDictionary *)settings error:(NSError **)outError;


- (BOOL)prepareToRecord;
 録音の準備を行う。
- (BOOL)record;
 録音を行う
- (BOOL)recordForDuration: (NSTimeInterval) duration;
 遅延録音する

  • (void)pause;

 ポーズする
- (void)stop;
 録音を停止する

- (BOOL)deleteRecording;

@property(readonly, getter=isRecording) BOOL recording;

@property(readonly) NSURL *url;

@property(readonly) NSDictionary *settings;

@property(assign) id delegate;


@property(readonly) NSTimeInterval currentTime;


@property(getter=isMeteringEnabled) BOOL meteringEnabled;

- (void)updateMeters;

- (float)peakPowerForChannel:(NSUInteger)channelNumber;
- (float)averagePowerForChannel:(NSUInteger)channelNumber;


- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag;


- (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *)recorder error:(NSError *)error;


- (void)audioRecorderBeginInterruption:(AVAudioRecorder *)recorder;


- (void)audioRecorderEndInterruption:(AVAudioRecorder *)recorder;

- (id)initWithContentsOfURL:(NSURL *)url error:(NSError **)outError;
- (id)initWithData:(NSData *)data error:(NSError **)outError;


- (BOOL)prepareToPlay;
 再生の準備を行う
- (BOOL)play;
 再生を行う
- (void)pause;
 ポーズする(バッファはクリアしない)
- (void)stop;
 再生をストップする(バッファをクリアする)


@property(readonly, getter=isPlaying) BOOL playing;

@property(readonly) NSUInteger numberOfChannels;
@property(readonly) NSTimeInterval duration;

@property(assign) id delegate;


@property(readonly) NSURL *url;
@property(readonly) NSData *data;

@property float volume;

@property NSTimeInterval currentTime;

@property NSInteger numberOfLoops;



@property(getter=isMeteringEnabled) BOOL meteringEnabled;

- (void)updateMeters;

- (float)peakPowerForChannel:(NSUInteger)channelNumber;
- (float)averagePowerForChannel:(NSUInteger)channelNumber;


- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag;
 再生が完了したことを通知
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error;
 エラーが発生したことを通知

iPhoneのみ
- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player;
 サウンド再生の中断通知
- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player;
 サウンド再生の再開通知