LoginSignup
2
2

More than 1 year has passed since last update.

【Swift】動画撮影時にシステムサウンドを鳴らす方法

Last updated at Posted at 2021-06-18

動画撮影時にシステムサウンドを鳴らす方法

デフォルトのカメラアプリの様に録画開始、終了時にポンッという効果音を鳴らしたい時に参考にしていただければ幸いです。

コード

import AudioToolbox
 @objc func tappedRecordButton(sender: UIButton) {
  //録画開始サウンド
  var soundIdRing:SystemSoundID = 1117
  //録画終了時は var soundIdRing:SystemSoundID = 1118
  if let soundUrl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), nil, nil, nil){
   AudioServicesCreateSystemSoundID(soundUrl, &soundIdRing)
   AudioServicesPlaySystemSound(soundIdRing)
  }
 }

参考記事

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