IOS_AudioToolbox sound effects

Source: Internet
Author: User

1. AudioToolbox Overview

Through the AudioToolbox framework, you can register a short sound to the system sound service. The sound registered to the system sound service is called system sounds. It must meet the following conditions.

(1). the playback time cannot exceed 30 seconds
(2) the data must be in PCM or IMA4 stream format.
(3). It must be packaged into one of the following three formats: Core Audio Format (. caf), Waveform audio (.wav), or Audio Interchange File (. aiff)
Sound files must be placed under the Local folder of the device. Use the AudioServicesCreateSystemSoundID method to register this sound file.

2. Use AudioToolbox
#import 

- (SystemSoundID)loadSound:(NSString *)name{    NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];    NSURL *url = [NSURL fileURLWithPath:path];    SystemSoundID soundID;    AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID);        return soundID;}

_ ClickID = [self loadSound: @ "click the button. aiff"]; AudioServicesPlaySystemSound (_ clickID); // vibrate AudioServicesPlaySystemSound (kSystemSoundID_Vibrate );


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.