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

时间:2015-05-17 11:55:00   收藏:0   阅读:1835

 

#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];

 

 

}

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!