0
내가 가진
여기에 같은 매우 비슷한 문제 : ViewController.h 파일에서 나는이 추가 link : 는 SystemSoundID는 아이폰 OS에 실패 만들기 - OSStatus을 = 0
#import <UIKit/UIKit.h>
#include <AudioToolbox/AudioToolbox.h>
@interface ViewController : UIViewController
@property SystemSoundID outSystemSoundID1;
@end
와 ViewController.m에서
그 :#import <ViewController.h>
@interface ViewController()
- (IBAction)playtrack;
@end
@implementation ViewController
@synthesize outSystemSoundID1;
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path1 = [[NSBundle mainBundle] pathForResource:@"1000Hz-0-4sec" ofType:@"wav"];
NSURL *url1 = [NSURL fileURLWithPath:path1];
//CFURLRef lol = (CFURLRef)objc_unretainedPointer(url1);
//AudioServicesCreateSystemSoundID(lol, &outSystemSoundID1);
OSStatus status = AudioServicesCreateSystemSoundID((__bridge CFURLRef)url1, &outSystemSoundID1);
NSLog(@"AudioServicesCreateSystemSoundID status = %ld", status);
}
- (IBAction)playtrack {
AudioServicesPlaySystemSound (outSystemSoundID1);
}
@end
재생할 사운드 파일이 보조 파일에 있습니다.
OSStatus는 말한다 : 당신이 밖으로 주석 부분에서 볼 수있는 것처럼
AudioServicesCreateSystemSoundID 상태 = 0
내가 다른 조합의 CFURLRef 제비를 위해 노력했다.
내 파일이 지원되지 않을 수 있습니다. 이 솔루션을 얻은 후 이런 식으로 aif 형식으로 3 개의 사운드 파일을 초기화하고 싶습니다.
희망을 보내주세요. 감사합니다 :)
내가 ARC가 활성화가 나는 아이폰 OS 6.0.1 (아이폰)에있어
하지만 단추를 누르면 응용 프로그램이 항상 중단되는 이유는 무엇입니까? (연결 대상은 - (IBAction) playtrack)? 이 메소드에 "(id) sender"를 추가해야합니까? – mrlowalowa
@mrlowalowa : 응용 프로그램이 충돌 할 때 오류 메시지가 나타 납니까? –
메인에서 autorelease로 지시 한 부분이 있습니다. 하지만이 ViewControll.C 파일에서 다른 IBAction을 실행했습니다. 내가 다른 버튼과 함께 넣은 후에 나는 소리를 들었다. ... 나는 잘 작동하고있는 3 가지 다른 methodes를 만들었지 만 differnet 버튼이나 그와 비슷한 방법으로 연결되지 않았다. 2 가지 IBActions가있는 경우 과부하가 걸릴 수 있습니다. – mrlowalowa