iphone - 声音不会在我的应用中播放

标签 iphone xcode audio

我已经启动了一个应用程序,启动该应用程序后,我需要一个音频剪辑。这是我的 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/

相关文章:

java - 使用java通过http循环流式传输音乐

iphone - 阻止 UIImageView 返回其在 View 中的原始位置?

iphone - `[super viewDidLoad]` 约定

IOS推特应用添加图片

objective-c - Xcode 在断点处停止时不显示代码

java - 处理中的多声道音频

ios - 如何让我的iPhone听超过特定阈值的声音频率?

objective-c - 具有 24 小时时间的 NSDateFormatter

iphone - 如何清除 map 图 block 的 MKMapView 缓存?

ios - 在需要从数据库计算的值时如何对 NSFetchedResultsController 更新使用react?