IOS growth Path-use system default sound, vibrate __ios

Source: Internet
Author: User
Tags uikit

turn from: http://blog.csdn.net/like7xiaoben/article/details/9001806


To import a frame:



Code:

[CPP] View plain copy #import <UIKit/UIKit.h> #import <AudioToolbox/AudioToolbox.h> @interface Msgpla Ysound:nsobject {Systemsoundid sound;//system sound ID range is: 1000-2000}-(ID) initsystemshake;//System vibration-(ID) init Systemsoundwithname: (NSString *) soundname soundtype: (NSString *) soundtype;//Initialize system sound-(void) play;//playback @end
[cpp]  View plain  copy #import   "MsgPlaySound.h"       @implementation   msgplaysound     -  (ID) initsystemshake   {        self = [super init];       if  (self)  {           sound = ksystemsoundid_vibrate;//Vibration        }       return self;  }      -  (ID) initsystemsoundwithname: (nsstring *) Soundname soundtype: (nsstring *) SoundType    {       self = [super init];        if  (self)  {           nsstring * path = [nsstring stringwithformat:@ "/system/library/audio/uisounds/%@.%@", SoundName,soundType];  &nbsP         //[[nsbundle bundlewithidentifier:@ "Com.apple.UIKit"  ]pathforresource:soundname oftype:soundtype];//get the Apple Framework resource uikit.framework&nbsp, remove the path of the system sound to play             //[[NSBundle mainBundle] URLForResource:  @ "tap"  withextension: @ "AIF"];   get custom sound             if  (path)  {                osstatus error = audioservicescreatesystemsoundid ((CFURLREF) [NSURL  Fileurlwithpath:path],&sound);                               if  (Error  != kaudioservicesnoerror)  {//Get the sound when the error occurred                     sound = nil;                }      &

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.