- Updated to iPhone X interface
- Adapted to Swift 4
- Uses iOS 11 large titles
- App now supports landscape mode and iPad
This is a small project demonstrating of how to locate and use system sound files. I hope this helps you.
- Lists all of the pre-installed system sounds on an iOS device from the
/System/Library/Audio/UISounds
and/Library/Ringtones
and their sub-folders. - Allows users to:
- Click to play the sound listed.
- Swipe from left to right to bookmark sounds for quick reference.
- Reorder or delete bookmarked sounds.
Unfortunately, this app WILL NOT WORK in the iOS simulator. You must run it on an iOS device (iPhone, iPad, iPod Touch).
I created this app to solve a particular problem. Wanting to take advantage of the system sounds already in the phone for a project I had a hard time finding documentation of the files saved in iOS 8 devices. I'm fairly certain that this will work on iOS 7 devices, but I'm not sure. I cannot test in the simulator nor do I have any devices still running iOS 7 (sorry).
This is a utility app for devlopers really. Not for the general public. I tried to keep the code and formatting as spartan as possible in order to not make things difficult to view and absorb. It's the bare minimum with a fair amount of comments to help new programmers.
- The app lists all of the user's bookmarked sounds (if any) as well as provides a link to browse all sounds in the
/System/Library/Audio/UISounds
and/Library/Ringtones
folders or deeper. - Click cells to play a sound.
- Swipe from right-to-left to bookmark a sound.
- Swipe bookmarked sounds to remove from bookmarks.
- Click "Edit" button to rearrange bookmarks and/or remove them.
- The app starts in the
/System/Library/Audio/UISounds
and/Library/Ringtones
folders and looks for any sub-directories on that level and puts them all in an array. - The app goes to each directory in that array a finds the sound files in each and saves them all in a
[NSDictionary]
array of dictionaries for programmatic access. - Bookmarked files are saved to the
NSUserDefaults
onviewWillDisappear
and loaded onviewWillAppear
.
The key piece is really
let fileURL: NSURL = NSURL(fileURLWithPath: "\{directory}\{filename}.{extension}")
do {
appController.audioPlayer = try AVAudioPlayer(contentsOf: fileURL)
appController.audioPlayer.play()
} catch {
debugPrint("\(error)")
}
All of the work in the app comes down to those few lines.
##References This was inspired by the iOSSystemSoundsLibrary by TUNER88.