在 iOS 应用中使用现有的系统声音 [swift| [英] Using existing system sounds in iOS App [swift|
问题描述
是否可以在我自己的应用程序中使用现有的 Apple 系统声音?我想用 Swift 编写一个示例应用程序,它执行以下步骤:
Is it possible to use the existing Apple system sounds in my own app? I would like to write a sample app in Swift that does the following steps:
- 读取/获取设备上所有可用系统声音的列表(我认为它们位于
/System/Library/Audio/UISounds/
) - 在屏幕上显示列表
- 如果我触摸列表项,就会播放这些声音
所以基本上是一样的,就像你在 iPhone 上选择新铃声一样.
So its basically the same, like when you choose a new ringtone on your iPhone.
我认为有些应用正在使用这种声音,或者他们是否复制/购买了它?
I think some apps are using this sounds, or have they copied/bought it?
感谢和问候延斯
推荐答案
您可以使用此 Swift 5 代码播放系统声音:
You can use this Swift 5 code to play system sounds:
// import this
import AVFoundation
// create a sound ID, in this case its the tweet sound.
let systemSoundID: SystemSoundID = 1016
// to play sound
AudioServicesPlaySystemSound(systemSoundID)
我能找到的最新声音列表是这里.
The most up to date list of sounds I could find are here.
这就是它们听起来的样子:https://www.youtube.com/watch?v=TjmkmIsUEbA
And this is what they all sound like: https://www.youtube.com/watch?v=TjmkmIsUEbA
这篇关于在 iOS 应用中使用现有的系统声音 [swift|的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!