首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在iOS中播放短小的自动声音并立即启动

在iOS中播放短小的自动声音并立即启动
EN

Stack Overflow用户
提问于 2011-09-27 18:25:43
回答 2查看 364关注 0票数 1

我有一个自产生的DTMF声音(与一个wav头)产生的程序,我希望能够快速播放,事实上,只要用户触摸一个按钮。这个DTMF声音必须无限地播放/循环,直到我停止为止。其他一些声音必须能够同时播放。

我对音频编程非常陌生,我测试了很多方法,现在我迷失了方向。

我怎样才能做到这一点?

需要:

  • 非常快的回放开始(包括第一次)
  • 多个声音同时发出(短音+- 2-6秒)
  • 无限无间隙DTMF声
  • 控制正在播放的不同声音[能够停止一个播放的声音]
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-09-28 10:53:14

AVAudioPlayer --如果你能忍受一些延迟,OpenAL (例如芬奇) --如果你真的需要尽可能低的延迟。

票数 1
EN

Stack Overflow用户

发布于 2011-09-28 11:02:55

我使用已经存在的.wav文件。我可以轻松地演奏。

用于运行以下代码。包括AudioToolbox框架。

写入.h文件#import <AudioToolbox/AudioToolbox.h>

写入.m文件

代码语言:javascript
运行
复制
-(IBAction)startSound{

    //Get the filename of the sound file:
    NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/sound1.wav"];

        //declare a system sound
        SystemSoundID soundID;

    //Get a URL for the sound file
    NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];

    //Use audio sevices to create the sound
    AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
    //Use audio services to play the sound
    [self sound];
    timer =[ [NSTimer scheduledTimerWithTimeInterval:2.1 target:self selector:@selector(sound) userInfo:nil repeats:YES]retain];

}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7573922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档