iOS系统声音列表

效果

说明

1. 点击cell就能发出声音

2. 只需要给出声音编号,就可以,非常简单易用

源码

https://github.com/YouXianMing/iOS-Utilities

//
// SystemSound.h
// SystemSound
//
// Created by YouXianMing on 15/8/24.
// Copyright (c) 2015年 YouXianMing. All rights reserved.
// #import <Foundation/Foundation.h>
#import "SoundInfomation.h" @interface SystemSound : NSObject /**
* 获取系统消息列表
*/
+ (void)accessSystemSoundsList; /**
* 系统声音的列表
*
* @return SoundInfomation对象数组
*/
+ (NSArray *)systemSounds; /**
* 播放声音
*
* @param sound 声音
*/
+ (void)playWithSound:(SoundInfomation *)sound; /**
* 根据声音ID号播放声音
*
* @param soundID 声音ID号码
*/
+ (void)playWithSoundID:(UInt32)soundID; @end
//
// SystemSound.m
// SystemSound
//
// Created by YouXianMing on 15/8/24.
// Copyright (c) 2015年 YouXianMing. All rights reserved.
// #import "SystemSound.h"
#import <AudioToolbox/AudioToolbox.h> static NSMutableArray *_systemSounds = nil; @implementation SystemSound + (void)accessSystemSoundsList { static dispatch_once_t predicate; dispatch_once(&predicate, ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{ NSMutableArray *audioFileList = [NSMutableArray array];
_systemSounds = [NSMutableArray array]; // 读取文件系统
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL *directoryURL = [NSURL URLWithString:@"/System/Library/Audio/UISounds"];
NSArray *keys = [NSArray arrayWithObject:NSURLIsDirectoryKey]; NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtURL:directoryURL
includingPropertiesForKeys:keys
options:
errorHandler:^(NSURL *url, NSError *error) {
return YES;
}]; for (NSURL *url in enumerator) { NSError *error;
NSNumber *isDirectory = nil;
if (! [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:&error]) { } else if (![isDirectory boolValue]) { [audioFileList addObject:url]; SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge_retained CFURLRef)url, &soundID); SoundInfomation *sound = [[SoundInfomation alloc] init];
sound.soundID = soundID;
sound.soundUrl = url;
sound.soundName = url.lastPathComponent; [_systemSounds addObject:sound];
}
} // 读取文件
NSString *path = [[NSBundle mainBundle] pathForResource:@"SystemSoundList" ofType:nil];
NSData *data = [[NSData alloc] initWithContentsOfFile:path]; NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray *array = [string componentsSeparatedByString:@"\n"]; for (int i = ; i < array.count; i++) { NSString *tmp = array[i]; NSArray *soundInfo = [tmp componentsSeparatedByString:@"\t"];
SoundInfomation *sound = [[SoundInfomation alloc] init]; sound.soundID = (unsigned int)[soundInfo[] integerValue];
sound.soundName = soundInfo[];
[_systemSounds addObject:sound];
}
});
});
} + (NSArray *)systemSounds { return _systemSounds;
} + (void)playWithSound:(SoundInfomation *)sound { AudioServicesPlaySystemSound(sound.soundID);
} + (void)playWithSoundID:(UInt32)soundID { AudioServicesPlaySystemSound(soundID);
} @end
//
// SoundInfomation.h
// SystemSound
//
// Created by YouXianMing on 15/8/24.
// Copyright (c) 2015年 YouXianMing. All rights reserved.
// #import <Foundation/Foundation.h> @interface SoundInfomation : NSObject /**
* 系统声音编号(必须有)
*/
@property (nonatomic) UInt32 soundID; /**
* 系统声音地址
*/
@property (nonatomic, strong) NSURL *soundUrl; /**
* 声音的名字
*/
@property (nonatomic, strong) NSString *soundName; @end
//
// SoundInfomation.m
// SystemSound
//
// Created by YouXianMing on 15/8/24.
// Copyright (c) 2015年 YouXianMing. All rights reserved.
// #import "SoundInfomation.h" @implementation SoundInfomation @end
    new-mail.caf    MailReceived
mail-sent.caf MailSent
Voicemail.caf VoicemailReceived
ReceivedMessage.caf SMSReceived
SentMessage.caf SMSSent
alarm.caf CalendarAlert
low_power.caf LowPower
sms-received1.caf SMSReceived_Alert
sms-received2.caf SMSReceived_Alert
sms-received3.caf SMSReceived_Alert
sms-received4.caf SMSReceived_Alert
- SMSReceived_Vibrate
sms-received1.caf SMSReceived_Alert
sms-received5.caf SMSReceived_Alert
sms-received6.caf SMSReceived_Alert
Voicemail.caf -
tweet_sent.caf SMSSent
Anticipate.caf SMSReceived_Alert
Bloom.caf SMSReceived_Alert
Calypso.caf SMSReceived_Alert
Choo_Choo.caf SMSReceived_Alert
Descent.caf SMSReceived_Alert
Fanfare.caf SMSReceived_Alert
Ladder.caf SMSReceived_Alert
Minuet.caf SMSReceived_Alert
News_Flash.caf SMSReceived_Alert
Noir.caf SMSReceived_Alert
Sherwood_Forest.caf SMSReceived_Alert
Spell.caf SMSReceived_Alert
Suspense.caf SMSReceived_Alert
Telegraph.caf SMSReceived_Alert
Tiptoes.caf SMSReceived_Alert
Typewriters.caf SMSReceived_Alert
Update.caf SMSReceived_Alert
ussd.caf USSDAlert
SIMToolkitCallDropped.caf SIMToolkitTone
SIMToolkitGeneralBeep.caf SIMToolkitTone
SIMToolkitNegativeACK.caf SIMToolkitTone
SIMToolkitPositiveACK.caf SIMToolkitTone
SIMToolkitSMS.caf SIMToolkitTone
Tink.caf PINKeyPressed
ct-busy.caf AudioToneBusy
ct-congestion.caf AudioToneCongestion
ct-path-ack.caf AudioTonePathAcknowledge
ct-error.caf AudioToneError
ct-call-waiting.caf AudioToneCallWaiting
ct-keytone2.caf AudioToneKey2
lock.caf ScreenLocked
unlock.caf ScreenUnlocked
- FailedUnlock
Tink.caf KeyPressed
Tock.caf KeyPressed
Tock.caf KeyPressed
beep-beep.caf ConnectedToPower
RingerChanged.caf RingerSwitchIndication
photoShutter.caf CameraShutter
shake.caf ShakeToShuffle
jbl_begin.caf JBL_Begin
jbl_confirm.caf JBL_Confirm
jbl_cancel.caf JBL_Cancel
begin_record.caf BeginRecording
end_record.caf EndRecording
jbl_ambiguous.caf JBL_Ambiguous
jbl_no_match.caf JBL_NoMatch
begin_video_record.caf BeginVideoRecording
end_video_record.caf EndVideoRecording
vc~invitation-accepted.caf VCInvitationAccepted
vc~ringing.caf VCRinging
vc~ended.caf VCEnded
ct-call-waiting.caf VCCallWaiting
vc~ringing.caf VCCallUpgrade
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-.caf TouchTone
dtmf-star.caf TouchTone
dtmf-pound.caf TouchTone
long_low_short_high.caf Headset_StartCall
short_double_high.caf Headset_Redial
short_low_high.caf Headset_AnswerCall
short_double_low.caf Headset_EndCall
short_double_low.caf Headset_CallWaitingActions
middle_9_short_double_low.caf Headset_TransitionEnd
Voicemail.caf SystemSoundPreview
ReceivedMessage.caf SystemSoundPreview
new-mail.caf SystemSoundPreview
mail-sent.caf SystemSoundPreview
alarm.caf SystemSoundPreview
lock.caf SystemSoundPreview
Tock.caf KeyPressClickPreview
sms-received1.caf SMSReceived_Selection
sms-received2.caf SMSReceived_Selection
sms-received3.caf SMSReceived_Selection
sms-received4.caf SMSReceived_Selection
- SMSReceived_Vibrate
sms-received1.caf SMSReceived_Selection
sms-received5.caf SMSReceived_Selection
sms-received6.caf SMSReceived_Selection
Voicemail.caf SystemSoundPreview
Anticipate.caf SMSReceived_Selection
Bloom.caf SMSReceived_Selection
Calypso.caf SMSReceived_Selection
Choo_Choo.caf SMSReceived_Selection
Descent.caf SMSReceived_Selection
Fanfare.caf SMSReceived_Selection
Ladder.caf SMSReceived_Selection
Minuet.caf SMSReceived_Selection
News_Flash.caf SMSReceived_Selection
Noir.caf SMSReceived_Selection
Sherwood_Forest.caf SMSReceived_Selection
Spell.caf SMSReceived_Selection
Suspense.caf SMSReceived_Selection
Telegraph.caf SMSReceived_Selection
Tiptoes.caf SMSReceived_Selection
Typewriters.caf SMSReceived_Selection
Update.caf SMSReceived_Selection
- RingerVibeChanged
- SilentVibeChanged
- Vibrate

iOS系统声音列表的更多相关文章

  1. iOS系统声音服务(System Sound Services)

    系统声音服务(System Sound Services)提供了一个接口,用于播放不超过30秒的声音.它支持的文件格式有限,具体地说只有CAF.AIF和使用PCM或IMA/ADPCM数据的WAV文件. ...

  2. iOS 之播放系统声音

    导入框架: 代码: #import <UIKit/UIKit.h> #import <AudioToolbox/AudioToolbox.h> @interface MsgPl ...

  3. IOS调用系统声音(键盘声音)

    #import <AudioToolbox/AudioToolbox.h> AudioServicesPlaySystemSound(1106); 注:括号中为系统声音的id,详见 htt ...

  4. ios开发——实用技术篇Swift篇&系统声音

    系统声音 // MARK: - 系统声音 /*----- 系统声音 ------*/ @IBAction func systemSound() { //建立的SystemSoundID对象 var s ...

  5. iOS调用系统声音与振动

    如何调用系统声音?[iphone 调用系统铃声与震动功能] 首先要在工程里加入Audio Toolbox framework这个库,然后在需要调用的文件里#import <AudioToolbo ...

  6. iOS 接收新消息通知调用系统声音 震动

    添加系统框架: #import <AudioToolbox/AudioToolbox.h> 调用震动代码: AudioServicesPlaySystemSound(kSystemSoun ...

  7. 深入了解ios系统机制

    1.什么叫ios?        ios一般指ios(Apple公司的移动操作系统) .        苹果iOS是由苹果公司开发的移动操作系统.苹果公司最早于2007年1月9日的Macworld大会 ...

  8. iOS系统层次架构

    本文转自:http://blog.csdn.net/lxl_815520/article/details/51172917 一,概述 iOS的系统架构分为四个层次:核心操作系统层(Core OS la ...

  9. ios系统提示音的使用(不是铃声)

    AudioServices Jump to: navigation, search AudioServices is a group of C functions in AudioToolbox fo ...

随机推荐

  1. eclipse中explorer显示方式

    不知道是不是上面的描述.做个记录 project explorer 项目资源管理器 这个要打开代码目录需要再点开java resources 还会出现deployment Descriptor项目工程 ...

  2. synchronized修饰方法和对象的区别

    使用synchronized(object) { 代码块.... } 能对代码块进行加锁,不允许其他线程访问,其的作用原理是:在object内有一个变量,当有线程进入时,判断是否为0,如果为0,表示可 ...

  3. SSL编程(1) 概述

    文章来自本园马若望 SSL是TCP/IP环境上的标准的安全加密传输协议.SSL的全称是安全的 Socket层,它具有与Socket类似的客户端/服务器体制.常见的https即http+ssl,从安全的 ...

  4. 深入了解Java虚拟机(2)垃圾收集器与内存分配策略

    垃圾收集器与内存分配策略 由于JVM中对象的频繁操作是在堆中,所以主要回收的是堆内存,方法区中的回收也有,但是比较谨慎 一.对象死亡判断方法 1.引用计数法 就是如果对象被引用一次,就给计数器+1,否 ...

  5. 本地git关联远程github

    0. 前言 我们开发的项目,均在本地开发:为了保证项目进度的一致性和公开性等,我们通常将开发过程代码或成品放置到github中,本文就讲述如何使得本地git与远程github同步! PS:以下两个名称 ...

  6. Socket编程 - 网络基础知识

    API编程部分:http://www.cnblogs.com/Jimmy1988/p/7895213.html 1. 协议简介 此处,我们主要介绍Linux编程常用的三种协议(TCP/UDP/IP), ...

  7. C#基础知识回顾--BackgroundWorker介绍

    简介 BackgroundWorker是.net里用来执行多线程任务的控件,它允许编程者在一个单独的线程上执行一些操作.耗时的操作(如下载和数据库事务)在长时间运行时可能会导致用户界面 (UI) 始终 ...

  8. BG.Sqoop

    1. 下载 Sqoop,并复制到虚拟机 http://sqoop.apache.org/ 2. 安装Sqoop tar zxf sqoop-1.4.6.bin__hadoop-2.0.4-alpha. ...

  9. Grunt - 安装指南

    发现周围有些人对前端存在偏见. 他们认为前端只是用没那么复杂的技术对着界面调来调去,一点点打磨,最后做出一个没什么实用价值的“花瓶”. 其实,前端的技术栈并不简单,比如我们可以用Grunt进行一些自动 ...

  10. Jquery Easy UI初步学习(三)数据增删改

    第二篇只是学了加载用datagrid加载数据,数据的增删改还没有做,今天主要是解决这个问题了. 在做增删改前需要弹出对应窗口,这就需要了解一下EasyUi的弹窗控件. 摘自:http://philoo ...