Swift - 系统声音服务的使用(播放声音,提醒,震动)
1,系统声音服务介绍:
|
1
|
import AudioToolbox |
(1)声音播放
|
1
2
3
4
5
6
7
8
9
10
11
12
|
@IBAction func systemSound(sender: AnyObject) { //建立的SystemSoundID对象 var soundID:SystemSoundID = 0 //获取声音地址 var path = NSBundle.mainBundle().pathForResource("msg", ofType: "wav") //地址转换 var baseURL = NSURL(fileURLWithPath: path!) //赋值 AudioServicesCreateSystemSoundID(baseURL, &soundID) //播放声音 AudioServicesPlaySystemSound(soundID)} |
(2)提醒
|
1
2
3
4
5
6
7
8
9
10
11
12
|
@IBAction func systemAlert(sender: AnyObject) { //建立的SystemSoundID对象 var soundID:SystemSoundID = 0 //获取声音地址 var path = NSBundle.mainBundle().pathForResource("msg", ofType: "wav") //地址转换 var baseURL = NSURL(fileURLWithPath: path!) //赋值 AudioServicesCreateSystemSoundID(baseURL, &soundID) //提醒(同上面唯一的一个区别) AudioServicesPlayAlertSound(soundID)} |
(3)振动
|
1
2
3
4
5
6
|
@IBAction func systemVibration(sender: AnyObject) { //建立的SystemSoundID对象 var soundID = SystemSoundID(kSystemSoundID_Vibrate) //振动 AudioServicesPlaySystemSound(soundID)} |
Swift - 系统声音服务的使用(播放声音,提醒,震动)的更多相关文章
- iOS系统声音服务(System Sound Services)
系统声音服务(System Sound Services)提供了一个接口,用于播放不超过30秒的声音.它支持的文件格式有限,具体地说只有CAF.AIF和使用PCM或IMA/ADPCM数据的WAV文件. ...
- ios开发——实用技术篇Swift篇&系统声音
系统声音 // MARK: - 系统声音 /*----- 系统声音 ------*/ @IBAction func systemSound() { //建立的SystemSoundID对象 var s ...
- iOS 之播放系统声音
导入框架: 代码: #import <UIKit/UIKit.h> #import <AudioToolbox/AudioToolbox.h> @interface MsgPl ...
- iOS系统声音列表
iOS系统声音列表 效果 说明 1. 点击cell就能发出声音 2. 只需要给出声音编号,就可以,非常简单易用 源码 https://github.com/YouXianMing/iOS-Utilit ...
- 使用 Python 的 sounddevice 包录制系统声音
博客中的文章均为meelo原创,请务必以链接形式注明本文地址 sounddevice是一个与Numpy兼容的录音以及播放声音的包. 安装sounddevice包 直接通过pip就能安装. pip in ...
- IOS调用系统声音(键盘声音)
#import <AudioToolbox/AudioToolbox.h> AudioServicesPlaySystemSound(1106); 注:括号中为系统声音的id,详见 htt ...
- 是智能手机推动windows xp系统停止服务吗
昨天是windows xp系统停止服务的大限,各大媒体争相报道,漫天铺地的xp消息充斥网络,xp这个词的百度指数这段时间从4月1日的8411也开始猛涨,特别是这两天4月7日的36470飙升到4月8日的 ...
- Linux 系统Telnet服务
Linux 系统Telnet服务 telnet与ssh相比,安全性能并不高,但是在ssh版本升级或者其他的情况下还是需要开启这一项服务.linux提供服务是由运行在后台的守护进程daemon来执行的, ...
- iOS调用系统声音与振动
如何调用系统声音?[iphone 调用系统铃声与震动功能] 首先要在工程里加入Audio Toolbox framework这个库,然后在需要调用的文件里#import <AudioToolbo ...
随机推荐
- C++,常成员函数
#include <iostream> using namespace std; class Test { public: int x; int y; void const_m1() co ...
- 机器学习笔记(二)- from Andrew Ng的教学视频
省略了Octave的使用方法结束,以后用得上再看吧 week three: Logistic Regression: 用于0-1分类 Hypothesis Representation: :Sigmo ...
- java实现随机验证码的图片
链接地址:http://blog.sina.com.cn/s/blog_407a68fc010006qo.html 1.一共需要2个常用java文件(RandomCode.java和RandomCod ...
- html5 学习笔记
一.ie8及以下对html5相关语义标签的支持 <!-[if lt IE9]> <script src="html5.js"></script> ...
- Python 模块(五)
目录 模块介绍 time &datetime模块 random json & picle 一.模块介绍 在我们日常的程序开发过程中,随着代码越写越多,在单个文件里的代码就会越来越长,越 ...
- Java--再次理解多态
Java中多态性(polymorphism)的实现 什么是多态 1. 面向对象的三大特性:封装.继承.多态.从一定角度来看,封装和继承几乎都是为多态而准备的.这是我们最后一个概念,也是最重要的知识点. ...
- CodeForces 543A - Writing Code DP 完全背包
有n个程序,这n个程序运作产生m行代码,但是每个程序产生的BUG总和不能超过b, 给出每个程序产生的代码,每行会产生ai个BUG,问在总BUG不超过b的情况下, 我们有几种选择方法思路:看懂了题意之后 ...
- pay包注释(二)
@login_required()def to_register(request): return render_to_response("pay/register_yeepay.ht ...
- linux c 得到文件大小
#include <sys/stat.h> unsigned long get_file_size(const char *path) { unsigned long filesize = ...
- 基于visual Studio2013解决C语言竞赛题之0608水仙花函数
题目 解决代码及点评 /* 功能:写一函数判断某数是否"水仙花数",所谓"水仙花数"是指一个三位数, 其各位数字立方和等于该数本身. */ #includ ...