1
私のアプリケーションでは次の問題があります。再生ボタンを押すと、mp3が再生を開始し、アプリケーションも終了します。Xcodeでオーディオ(mp3)を再生する際の問題
SongDetailsViewController.h
#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>
@interface SongDetailsViewController : UIViewController <AVAudioPlayerDelegate> {
AVAudioPlayer *player;
NSString *songID;
NSString *species;
}
- (void) dismissModal:(id)sender;
- (IBAction) playCall:(id)sender;
- (IBAction) pauseCall:(id)sender;
- (IBAction) stopCall:(id)sender;
@property (nonatomic, retain) AVAudioPlayer *player;
@property (nonatomic, copy) NSString *songID;
@property (nonatomic, copy) NSString *species;
@end
そしてSongDetailsViewController.m
- (IBAction) pauseCall:(id)sender{
[player pause];
}
- (IBAction) stopCall:(id)sender
{
[player stop];
}
- (IBAction) playCall:(id)sender{
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *songPath = [documentsDir stringByAppendingPathComponent:@"songs"];
NSString *mySongPath = [songPath stringByAppendingPathComponent:[songID stringByAppendingString:@".mp3"]];
NSURL *file = [[NSURL alloc] initFileURLWithPath:mySongPath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:file error:nil];
player.delegate=self;
[player prepareToPlay];
[player play];
}
エラー・スタック。
2011-12-29 20:04:40.508 Bird Call Player[6266:307] -[SongDetailsViewController playNote:]: unrecognized selector sent to instance 0x1bcdb0
2011-12-29 20:04:40.531 Bird Call Player[6266:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SongDetailsViewController playNote:]: unrecognized selector sent to instance 0x1bcdb0'
*** Call stack at first throw:
(
0 CoreFoundation 0x344aaed3 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x33975811 objc_exception_throw + 24
2 CoreFoundation 0x344ac683 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x344541d9 ___forwarding___ + 508
4 CoreFoundation 0x34453f90 _CF_forwarding_prep_0 + 48
5 CoreFoundation 0x34452719 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
6 UIKit 0x31b30141 -[UIApplication sendAction:to:from:forEvent:] + 84
7 UIKit 0x31b300e1 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
8 UIKit 0x31b300b3 -[UIControl sendAction:to:forEvent:] + 38
9 UIKit 0x31b2fe05 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
10 UIKit 0x31b30453 -[UIControl touchesEnded:withEvent:] + 342
11 UIKit 0x31b2eddd -[UIWindow _sendTouchesForEvent:] + 368
12 UIKit 0x31b2e757 -[UIWindow sendEvent:] + 262
13 UIKit 0x31b299ff -[UIApplication sendEvent:] + 298
14 UIKit 0x31b29337 _UIApplicationHandleEvent + 5110
15 GraphicsServices 0x3026c04b PurpleEventCallback + 666
16 CoreFoundation 0x3443fce3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
17 CoreFoundation 0x3443fca7 __CFRunLoopDoSource1 + 166
18 CoreFoundation 0x3443256d __CFRunLoopRun + 520
19 CoreFoundation 0x34432277 CFRunLoopRunSpecific + 230
20 CoreFoundation 0x3443217f CFRunLoopRunInMode + 58
21 GraphicsServices 0x3026b5f3 GSEventRunModal + 114
22 GraphicsServices 0x3026b69f GSEventRun + 62
23 UIKit 0x31ad-[UIApplication _run] + 402
24 UIKit 0x31ace12f UIApplicationMain + 670
25 Bird Call Player 0x000026cb main + 122
26 Bird Call Player 0x00002114 start + 40
)
terminate called after throwing an instance of 'NSException'
私はinitWithNibName
にplayCall内のコードを移動した場合、それが正常に動作します。誰かが私がやった間違いが何であるか把握する手助けができますか?
事前に
あなたのプレイノート機能はどこにありますか? [SongDetailsViewController playNote:]:インスタンスに送信された認識できないセレクタ – Lefteris