零碎的小知识点记录
一、语音播放
- (void)creatLanguageEnvironment
{
AVSpeechSynthesisVoice * vioce = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // 语言
//通过如下方法可以查看所支持的语言,可根据需要从中选取所需语言
// NSArray *voices = [AVSpeechSynthesisVoice speechVoices];
// 常用语言如下:
// en-GB//英语(英式)
// en-US//英语(美式)
// zh-CN//汉语(普通话)
// zh-HK//汉语(粤语)
// zh-TW//汉语(台湾)
AVSpeechUtterance * utterance = [AVSpeechUtterance speechUtteranceWithString:@"goodmorning everyone"]; // 声音相关设置
utterance.voice = vioce;
utterance.rate = 0.5;
utterance.volume = 1;
utterance.pitchMultiplier = 1;
utterance.preUtteranceDelay = 1;
utterance.postUtteranceDelay = 1;
AVSpeechSynthesizer * synthesizer = [[AVSpeechSynthesizer alloc]init]; // 合成器
[synthesizer speakUtterance:utterance];
}
二、提示音震动
某一天某一次打王者荣耀的时候才感受到原来手机震动了,想着如何使iPhone震动,就实践了。
- (void)shanke{
// SystemSoundID soundID = 0;
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(1006);
// AudioServicesCreateSystemSoundID(<#CFURLRef _Nonnull inFileURL#>, <#SystemSoundID * _Nonnull outSystemSoundID#>) // 通过路径播放本地资源音频文件
// AudioServicesDisposeSystemSoundID(soundID);
}