【发布时间】:2014-03-13 16:03:32
【问题描述】:
我试图在 iOS 中播放一首歌曲,但它给了我一条错误消息。
头文件.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface PRPViewController : UIViewController{
AVAudioPlayer *audioPlayer;
IBOutlet UIButton *start;
}
-(IBAction)play;
@end
实现文件.m
NSURL *url = [NSURL fileURLWithPath:
[NSString stringWithFormat:@"%@/bobmarley.mp3",
[[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsofURL:url error:&error];
audioPlayer.numberOfLoops = 0;
[audioPlayer play];
但它说
AVAudioPlayer 没有可见的@interface 声明选择器“initWithContentsofUrl:error:”
我该怎么办?
【问题讨论】:
标签: ios objective-c avaudioplayer audio-player