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);
    }
  • 相关阅读:
    git stash功能的使用
    git tag的应用
    git merge 与 git rebase的区别?
    git的一些操作命令
    docker的常用操作
    lvs搭建dr负载均衡集群
    centos8安装lvs
    centos8安装docker
    centos8用firewalld搭建防火墙
    openresty上安装waf
  • 原文地址:https://www.cnblogs.com/-ios/p/6088563.html
Copyright © 2011-2022 走看看