#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的更多相关文章

  1. cocosbuilder中的Callbacks和sound effects

    cocosbuilder3中有增加了 Callback和sound effects 的timeline 这个东西用来在动画播放过程中控制音效和回调动作,非常方便 按住option键(alt), 点击t ...

  2. iOS系统声音服务(System Sound Services)

    系统声音服务(System Sound Services)提供了一个接口,用于播放不超过30秒的声音.它支持的文件格式有限,具体地说只有CAF.AIF和使用PCM或IMA/ADPCM数据的WAV文件. ...

  3. A JavaFX based Game Authoring System

    http://www.mirkosertic.de/doku.php/javastuff/javafxgameauthoring ——————————————————————————————————— ...

  4. 第十六章:自定义push notification sound

    前面一节已经讲过如何在ionic中集成jpush,这样我们的hybrid app在部署到ios或者android上面的时候,就可以接收通知了.如果不满足系统自带的声音,可以通过一些方式来播放自定义的通 ...

  5. System.map文件的作用

    有关System.map文件的信息好象很缺乏.其实它一点也不神秘,并且在整个事情当中它并不象看上去那么得重要.但是由于缺乏必要的文档说明,使其显得比较神秘.它就象耳垂,我们每个人都有,但却不知道是干什 ...

  6. System.map文件的作用解析

    有关System.map文件的信息好象很缺乏.其实它一点也不神秘,并且在整个事情当中它并不象看上去那么得重要.但是由于缺乏必要的文档说明,使其显得比较神秘.它就象耳垂,我们每个人都有,但却不知道是干什 ...

  7. Cocos2d-x之Sound

    |   版权声明:本文为博主原创文章,未经博主允许不得转载. 音效简介: 1.1 在游戏开发的过程中除了华丽的界面,生动的动画之外,适当的音效也是重要的一部分 1.2 游戏中的声音分为两类,一类是音乐 ...

  8. iOS苹果官方Demo合集

    Mirror of Apple’s iOS samples This repository mirrors Apple’s iOS samples. Name Topic Framework Desc ...

  9. .net Framework Class Library(FCL)

    from:http://msdn.microsoft.com/en-us/library/ms229335.aspx 我们平时在VS.net里引用的那些类库就是从这里来的 The .NET Frame ...

随机推荐

  1. Windows Store App 全球化 资源匹配规则

    上面几个小节通过示例介绍了如何引用资源以及设置应用语言来显示不同语言的信息,这些示例都只是添加了简体中文和英语两种语言来显示资源,而在一些复杂的应用程序中,字符串资源可能会被定义成多种语言,文件资源也 ...

  2. blade and soul zone overview

    The world of Blade and Soul, is a vast extension of land containing two continents (the Southern Con ...

  3. 小游戏Step表

    [Config]1|0|0|2|172,120,134|公主的记忆|1|2[Config] [Config]2|1|1|2|172,120,134|公主的记忆|1|2[Config] [Config] ...

  4. MRPT笔记——使用编译好的MRPT库建立VS2013项目

    接着上一篇<MRPT在VS2013中的配置>,下面接收如何使用编译好的MRPT建立工程项目. 一.设置环境变量 上一篇中,配置MRPT时,使用到了几个相关库,opencv.zlib.wxW ...

  5. listview指定某item的点击效果

    需求:listview的某些item能够点击,需要点击效果,有些item不能点击,需要屏蔽点击效果. 实现: 1.layout: <ListView android:id="@+id/ ...

  6. install vim-powerline

    1, install pip dnf install python-pip 2,install powerline-status pip install git+git://github.com/Lo ...

  7. ibatis入门教程

    转载自  http://www.cnblogs.com/ycxyyzw/archive/2012/10/13/2722567.html iBatis 简介: iBatis 是apache 的一个开源项 ...

  8. Read excel and put cell data into HashMap

    //Read excel row by row, put cell name and cell value to a map for each row. HashMap getExpectedResu ...

  9. js①

    JavaScript的引入方式 直接在script标签内部书写代码 ```html <!DOCTYPE html> ``` 2. 通过script标签的src属性,引入外部的JavaScr ...

  10. 访问本地Access 数据出错

    访问本地的access数据库时,出现了OleDbException 10Aug2015 晚: 好像找到了问题所在, 虽然不知道背后深层次的原因 改用了C#, 然后command 语句里也update了 ...