我已经启动了一个应用程序,启动该应用程序后,我需要一个音频剪辑。这是我的 View controller.m文件:
//
// ViewController.m
// audio test
//
// Created by Kevin Patrick on 14/07/2012.
// Copyright (c) 2012 Team Tops. All rights reserved.
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
@end
@implementation ViewController
-(void)awakeFromNib {
NSString *path = [[NSBundle mainBundle]
pathForResource:@"CPOP MUSIC"ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc]
initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
@end
但是,当我模拟该应用程序不会播放任何声音时,它是空白的,什么也不做。我在支持文件文件夹中找到了音频文件,我看到了有关最新Xcode的问题,但该文件仍然无法播放,我是初学者,所以请放轻松,谢谢:)
最佳答案
关于iphone - 声音不会在我的应用中播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11486873/