4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

waveファイルをiOSのシステムサウンドとして鳴らす方法

Last updated at Posted at 2013-10-10

iOSでシステムサウンドとして使用出来るファイルは、以下を満たす必要がある。

  • 長さは30秒以内
  • フォーマットは、リニアPCM or IMA4(IMA/ADPCM)
  • ファイル形式は、".caf" or ".aif" or ".wav"

参考:公式リファレンス System Sound Services Reference

例:sound.wavというファイルを鳴らす場合(※ AudioToolbox.frameworkが必要)

# import <AudioToolbox/AudioToolbox.h>

SytemSoundID *mBeep;

// システムサウンド生成
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &mBeep);

// 再生
AudioServicesPlaySystemSound(mBeep);

// 破棄
AudioServicesDisposeSystemSoundID(mBeep);
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?