LoginSignup
8
2

More than 5 years have passed since last update.

Swift:macOSのシステムサウンドを鳴らす

Posted at

macOSプリセットのシステムサウンドを鳴らす処理は非常に簡単に実装可能です.
Mojave時点で14種類の音を再生可能なようです.
サウンドファイルの実体が置いてある場所
/System/Library/Sounds/

NSSound
NSSound(named: "Basso")?.play()
NSSound(named: "Blow")?.play()
NSSound(named: "Bottle")?.play()
NSSound(named: "Frog")?.play()
NSSound(named: "Funk")?.play()
NSSound(named: "Glass")?.play()
NSSound(named: "Hero")?.play()
NSSound(named: "Morse")?.play()
NSSound(named: "Ping")?.play()
NSSound(named: "Pop")?.play()
NSSound(named: "Purr")?.play()
NSSound(named: "Sosumi")?.play()
NSSound(named: "Submarine")?.play()
NSSound(named: "Tink")?.play()

なお,音量はシステムの音量に依存します.

8
2
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
8
2