System Sounds: Alerts and Sound Effects
#include <AudioToolbox/AudioToolbox.h>
#include <CoreFoundation/CoreFoundation.h> // Define a callback to be called when the sound is finished
// playing. Useful when you need to free memory after playing.
static void MyCompletionCallback (
SystemSoundID mySSID,
void * myURLRef
) {
AudioServicesDisposeSystemSoundID (mySSID);
CFRelease (myURLRef);
CFRunLoopStop (CFRunLoopGetCurrent());
} int main (int argc, const char * argv[]) {
// Set up the pieces needed to play a sound.
SystemSoundID mySSID;
CFURLRef myURLRef;
myURLRef = CFURLCreateWithFileSystemPath (
kCFAllocatorDefault,
CFSTR ("../../ComedyHorns.aif"),
kCFURLPOSIXPathStyle,
FALSE
); // create a system sound ID to represent the sound file
OSStatus error = AudioServicesCreateSystemSoundID (myURLRef, &mySSID); // Register the sound completion callback.
// Again, useful when you need to free memory after playing.
AudioServicesAddSystemSoundCompletion (
mySSID,
NULL,
NULL,
MyCompletionCallback,
(void *) myURLRef
); // Play the sound file.
AudioServicesPlaySystemSound (mySSID); // Invoke a run loop on the current thread to keep the application
// running long enough for the sound to play; the sound completion
// callback later stops this run loop.
CFRunLoopRun ();
return 0;
}
System Sounds: Alerts and Sound Effects的更多相关文章
- cocosbuilder中的Callbacks和sound effects
cocosbuilder3中有增加了 Callback和sound effects 的timeline 这个东西用来在动画播放过程中控制音效和回调动作,非常方便 按住option键(alt), 点击t ...
- iOS系统声音服务(System Sound Services)
系统声音服务(System Sound Services)提供了一个接口,用于播放不超过30秒的声音.它支持的文件格式有限,具体地说只有CAF.AIF和使用PCM或IMA/ADPCM数据的WAV文件. ...
- A JavaFX based Game Authoring System
http://www.mirkosertic.de/doku.php/javastuff/javafxgameauthoring ——————————————————————————————————— ...
- 第十六章:自定义push notification sound
前面一节已经讲过如何在ionic中集成jpush,这样我们的hybrid app在部署到ios或者android上面的时候,就可以接收通知了.如果不满足系统自带的声音,可以通过一些方式来播放自定义的通 ...
- System.map文件的作用
有关System.map文件的信息好象很缺乏.其实它一点也不神秘,并且在整个事情当中它并不象看上去那么得重要.但是由于缺乏必要的文档说明,使其显得比较神秘.它就象耳垂,我们每个人都有,但却不知道是干什 ...
- System.map文件的作用解析
有关System.map文件的信息好象很缺乏.其实它一点也不神秘,并且在整个事情当中它并不象看上去那么得重要.但是由于缺乏必要的文档说明,使其显得比较神秘.它就象耳垂,我们每个人都有,但却不知道是干什 ...
- Cocos2d-x之Sound
| 版权声明:本文为博主原创文章,未经博主允许不得转载. 音效简介: 1.1 在游戏开发的过程中除了华丽的界面,生动的动画之外,适当的音效也是重要的一部分 1.2 游戏中的声音分为两类,一类是音乐 ...
- iOS苹果官方Demo合集
Mirror of Apple’s iOS samples This repository mirrors Apple’s iOS samples. Name Topic Framework Desc ...
- .net Framework Class Library(FCL)
from:http://msdn.microsoft.com/en-us/library/ms229335.aspx 我们平时在VS.net里引用的那些类库就是从这里来的 The .NET Frame ...
随机推荐
- Oracle中查看所有表和字段以及表注释.字段注释
获取表: select table_name from user_tables; //当前用户拥有的表 select table_name from all_tables; //所有用户的表 sele ...
- android xfermode绘图
1.fermode:是来自 transfer-modes,在画笔中设置xfermode后,画笔在使用的时候就会应用设置的像素转换模式.就类似于ps中的选取功能,留下的选取是从原选区中去除还是合并,取交 ...
- HTML引入外部文件,解决统一管理导航栏问题。
1.IFrame引入,看看下面的代码 <IFRAME NAME="content_frame" width=100% height=30 marginwidth=0 ...
- Javascript下拉导航
1.右侧导航 tree.js function Toggle(e){ if(!document.getElementById) return; if(!e) var e = window.event; ...
- 美化iTerm2
一.下载iTerm2,启动 二.安装oh-my-zsh curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/insta ...
- 不经过 App store 的安装方式(转)
所有安装到真机(非越狱)的应用(可以是 .app ,也可以是 .ipa ,只要编译时选的是编译成 Arm 的就好..app 转 .ipa 只需要一条命令) 都必须经过证书签名.证书主要有三大种: 企业 ...
- Log4J详解
Log4J 简介 Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和日志以何种形式输出.综合使 ...
- Storm进程通信机制
storm的worker进程之间消息传递机制图: 每个worker都有一个独立的监听进程,监听配置文件中配置过的端口列表supervisor.slots.ports,topology.receiver ...
- Microsoft .NET Framework 4.6.1
适用于操作系统平台:Windows 7 SP1.Windows 8.Windows 8.1.Windows 10.Windows Server 2008 R2 SP1.Windows Server 2 ...
- Perl技巧
项目里面一直用的是Perl,Perl里有各种小技巧就分享在这吧. push(@a, $b) 把b元素压入a数组中, 还可以有 push(@a, [@b]); 那a就成了二维数组了 scalar(@a) ...