您好我使用下面的代码来播放我的本地mp3文件。但没有错误来了。但是mp3没有播放。
protected $primaryKey = "item_id";
答案 0 :(得分:0)
检查以下步骤。
您的AppDelegate.m
#import <AVFoundation/AVAudioSession.h>`<AVFoundation/AVAudioSession.h>
您的application:didFinishLaunchingWithOptions:
方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
}
在ViewController.h中
@property (nonatomic,retain) AVAudioPlayer *audioPlayer ;
在您的ViewController.m
中@synthesize audioPlayer;
然后
NSString *sound_file;
if ((sound_file = [[NSBundle mainBundle] pathForResource:@"mpthreetest" ofType:@"mp3"])){
NSURL *url = [[NSURL alloc] initFileURLWithPath:sound_file];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
audioPlayer.delegate = self;
[audioPlayer prepareToPlay];
[audioPlayer play];
}
你犯的错误是你没有设置属性。