zoukankan      html  css  js  c++  java
  • 调用系统的提示音和振动

    调用系统的提示音和振动
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    //        soundId = kSystemSoundID_Vibrate;//振动
     
    - (id)initSytemShake{
        self = [super init];
        if (self) {
            AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    //        soundId = kSystemSoundID_Vibrate;//振动
        }
        return self;
    }
     
    - (id)initSytemSoundWithName:(NSString *)soundName soundType:(NSString *)soundType{
        self = [super init];
        if (self) {
            NSString * path = [NSString stringWithFormat:@"System/Library/Audio/UISounds/%@.%@",soundName,soundType];
    //        NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:soundName ofType:soundType]; //得到苹果框架资源
    //        [[NSBundle mainBundle] URLForResource:@"tap" withExtension:@"aif"];//获取自定义的声音
            if (path) {
                OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundId);
                if (error != kAudioServicesNoError) {// 获取的声音的时候,出现错误
                    soundId = 0;
                }
                
            }
        }
        return self;
    }
     
    - (void)play{
        AudioServicesPlaySystemSound(soundId);
    }
     
    - (void)free{
        AudioServicesDisposeSystemSoundID(soundId);
    }
  • 相关阅读:
    设计模式 --建造者模式
    HIVE
    Sqoop Mysql导入Hive完整命令参数解析
    Centos7 安装CDH6.3.2 集群
    sqlalchemy 批量插入
    前后端分离
    后台管理模板
    Springboot
    汇编基础
    百万点数据矢量切片实时聚合展示
  • 原文地址:https://www.cnblogs.com/-ios/p/6088563.html
Copyright © 2011-2022 走看看