iOS系统声音列表

iOS系统声音列表

 

效果

 

说明

1. 点击cell就能发出声音

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

 

源码

https://github.com/YouXianMing/SystemSound

//
//  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, 0), ^{

            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:0
                                                                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 = 0; i < array.count; i++) {

                NSString *tmp = array[i];

                NSArray         *soundInfo = [tmp componentsSeparatedByString:@"\t"];
                SoundInfomation *sound     = [[SoundInfomation alloc] init];

                sound.soundID   = (unsigned int)[soundInfo[0] integerValue];
                sound.soundName = soundInfo[1];
                [_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-0.caf    TouchTone
   dtmf-1.caf    TouchTone
   dtmf-2.caf    TouchTone
   dtmf-3.caf    TouchTone
   dtmf-4.caf    TouchTone
   dtmf-5.caf    TouchTone
   dtmf-6.caf    TouchTone
   dtmf-7.caf    TouchTone
   dtmf-8.caf    TouchTone
   dtmf-9.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
时间: 2024-10-30 15:55:03

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

ios 系统声音-系统声音使用MPVolumeView在8.4版本可以获取到系统音量的值,但在9.0的时候就获取不到

问题描述 系统声音使用MPVolumeView在8.4版本可以获取到系统音量的值,但在9.0的时候就获取不到 直接上代码: MPVolumeView volumeView = [[MPVolumeView alloc] init]; UISlider volumeViewSlider = nil; volumeView.frame = CGRectMake(-1000, -100, 100, 100); volumeView.hidden = NO; for (UIView view in [v

iOS 获取系统wifi列表,wifi信号强度,并给wifi设置密码,标签(副标题)

前言: iOS 9 发布之后,推出NetworkExtension, 它可给系统WiFi列表列表里边的WiFi设置密码 .标签(副标题). 还可获取整个WiFi列表. 首先你得向苹果申请一个权限,人家允许你使用了,你再在工程里面配置一下,这样你才可以使用.苹果会给你发个问卷调查,根据你自己的情况填写.这儿谢谢我初中学霸,专业的英语翻译果然6. 1-1.框架申请链接:https://developer.apple.com/contact/network-extension 问卷调查表 根据自己的实

苹果iOS系统下的推送机制及实现

苹果iOS系统下的推送机制及实现 浏览:785次  出处信息 本文译自http://www.raywenderlich.com.原文由iOS教程团队 Matthijs Hollemans 撰写,经原网站管理员授权本博翻译. 在iOS系统,考虑到手机电池电量,应用不允许在后台进行过多的操作,当用户未开启应用时,要怎么样才能通知用户呢? 好比用户收到一个新的微博.喜欢的球队取得一场胜利或者是晚餐准备好了,如果应用都不在运行当中,当然也就无法去获得这些事件. 幸运的是苹果提供一个解决方案,通过你自己的

电脑系统声音设置方法

一.如何对系统声音进行选择与设置? 系统声音的选择与设置就是为系统中的事件设置声音,当事件被激活时系统会根据用户的设置自动发出声音提示用户.选择系统声音的操作步骤如下: (1)在"控制面板"窗口中双击"声音及音频设备"图标,打开"声音及音频设备"属性对话框,它提供了检查配置系统声音环境的手段.这个对话框包含了音量.声音.音频.语声和硬件共5个选项卡. (2)在"声音"选项卡中,"程序事件"列表框中显示了当前

win7如何修改系统声音

win7如何修改系统声音 1.点击菜单,打开控制面板,点击声音. 2.点击声音窗口的声音选项. 3.声音方案下面是系统自带的一些声音,按自己的喜好选择. 4.如果都不喜欢,可以去下载一些自己喜欢的声音,在程序事件列表中选择要更改的声音.可以把下载好的声音文件放到C:WindowsMedia文件夹下, 系统自带的声音文件就在这个目录里.然后点击浏览. 5.选择要改的声音,点击打开.这是我下载的声音. 6.要改的声音就变成黄颜色的了,可以点击测试听一下声音,不喜欢再换.选好之后点确定,就OK了.

win7系统声音被禁用了如何恢复?

  win7系统声音被禁用了如何恢复?         1.你可以进行简单的检查.比如,音响电源.连线是否正常,机箱前置或后置接口是否正常.如果一切都正常,那么可以进行下一步' 2.打开"设备管理器",查看"声音.视频和游戏控制器"目录.通常,你会发现设备显示不正常.如下图,Realtek High Definition Audio正常,但是ATI HDMI Audio一栏却标有黄色叹号' 3.开启驱动精灵,建议下载最新的驱动精灵2011 Beta 2.查看&quo

三个智能调整Win7系统声音的实用技巧

  夜深人静时关机,最怕的就是那一段关机音乐,要是赶上个安装更新,电脑频繁自动重启,那就更惨了.其实,稍作设置就可以拒绝尴尬情况的发生: 手工关闭系统开.关机声音 Windows XP系统的那段开.关机音乐很长,手工关闭方法很简单:单击开始/控制面板,选择声音.语音和音频设备项,选择声音选项卡,直接在程序事件列表中找到启动Windows及退出Windows这两项,直接将声音设置为无,保存设置即可. 智能控制系统开.关机声音 手工设置固然绿色环保,但需要开启时又得手工操作.推荐Auto Mute这

win7更改系统声音教程

XP马上就要寿终正寝了,小编最近也急忙换了Windows 7,看不惯win7系统自带的开机/关机声音可以看一下本文.我只在win7系统测试过. win7更改系统声音教程: 1.点击菜单,打开控制面板,点击声音. 2.点击声音窗口的声音选项. 3.声音方案下面是系统自带的一些声音,按自己的喜好选择. 4.如果都不喜欢,可以去下载一些自己喜欢的声音,在程序事件列表中选择要更改的声音.可以把下载好的声音文件放到C:WindowsMedia文件夹下, 系统自带的声音文件就在这个目录里.然后点击浏览. 5

win7系统声音怎么设置?

  XP马上就要寿终正寝了,小编最近也急忙换了Windows 7,看不惯win7系统自带的开机/关机声音可以看一下本文.我只在win7系统测试过. win7更改系统声音教程: 1.点击菜单,打开控制面板,点击声音. 2.点击声音窗口的声音选项. 3.声音方案下面是系统自带的一些声音,按自己的喜好选择. 4.如果都不喜欢,可以去下载一些自己喜欢的声音,在程序事件列表中选择要更改的声音.可以把下载好的声音文件放到C:WindowsMedia文件夹下, 系统自带的声音文件就在这个目录里.然后点击浏览.