xcode 6.1:无法播放链接到按钮的WAV

时间:2015-02-10 07:22:58

标签: c++ ios objective-c iphone audio

我正在尝试为我创建的按钮添加声音wav。我相信我已经完成了所有必要的代码,但是我无法播放声音。有帮助吗?

我试图添加链接到我的按钮的wav文件。使用Audioserviceplay并创建功能,但仍然没有声音!     Hello world,我正在尝试为我创建的按钮添加声音wav。我相信我已经完成了所有必要的代码,但是我无法播放声音。有帮助吗?

我试图添加链接到我的按钮的wav文件。使用Audioserviceplay并创建功能,但仍然没有声音!

//
//  ViewController.m
//  Jets Soundboard
//
//  Created by Daniel Bernardin on 2015-02-09.
//  Copyright (c) 2015 Jets Sound. All rights reserved.
//

#import "ViewController.h"

#import <AudioToolbox/AudioToolbox.h>
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
   [  super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




- (IBAction)TrueNorth:(id)sender {
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"TrueNorth", CFSTR("wav"), NULL);
    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);



}
@end

0 个答案:

没有答案