码迷,mamicode.com
首页 > 移动开发 > 详细

IOS AVAudioPlayer 播放音频 没有声音问题解决

时间:2015-05-17 11:57:46      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:

 

#import <UIKit/UIKit.h>

#import <AVFoundation/AVFoundation.h>

@interface MainViewController : UIViewController<AVAudioPlayerDelegate>

 

@property(nonatomic,strong)AVAudioPlayer *movePlayer ;

@end

 

 

 

#import "MainViewController.h"

 

@interface MainViewController ()

 

@end

 

@implementation MainViewController

@synthesize movePlayer;

- (void)viewDidLoad {

    // Do any additional setup after loading the view.

 

    

    [super viewDidLoad];

 

    

    NSString *filePath = [[NSBundle mainBundle]  pathForResource:@"1111" ofType:@"mp3"];

    NSURL *url = [NSURL fileURLWithPath:filePath];

    

 

   movePlayer =[[AVAudioPlayer  alloc] initWithContentsOfURL:url error:nil];

 

    movePlayer.delegate=self;

    

    [movePlayer prepareToPlay];

    [movePlayer play];

 

 

}

IOS AVAudioPlayer 播放音频 没有声音问题解决

标签:

原文地址:http://www.cnblogs.com/lbjventure/p/4509280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!