iphone - 音频本地化

标签 iphone objective-c xcode audio localization

首先,我是一个n00b。
经过三天的尝试和研究,我决定寻求一些外部帮助。

我所做的和我的项目:

我为 children 写一本书。
现在,我正在本地化我的应用程序。
对于图像,我这样做是这样的:

UIImage *schrift = [UIImage imageNamed:NSLocalizedString (@"Schrift_en.png", nil)];
image = [[UIImageView alloc] initWithImage:schrift];
image.frame = CGRectMake(75.5, 80, 617, 137);
[self.view addSubview:image];
[image release];

对我来说很棒:)

现在,我正在尝试对讲述人音频文件执行相同的操作,但无法弄清楚该怎么做。
NSString *path = [[NSBundle mainBundle] pathForResource:@"Vorwort" ofType:@"mp3"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL   fileURLWithPath:path] error:NULL];
self.audioPlayer = theAudio;
[theAudio release];

我如何更改上面的代码以使其起作用,以及如何在Localizable.strings-file中定义ofType:@“mp3”?

Google无法帮助我。
有任何想法吗?
慢慢地,但是我肯定会失去动力。

如果有人可以帮助我,那将真的很酷!
提前致谢
浮游生物

最佳答案

试试这个

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], NSLocalizedString (@"audiofilename.mp3", nil)]];

AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
self.audioPlayer = theAudio;
[theAudio release];

关于iphone - 音频本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7208267/

相关文章:

swift - 从其他应用程序接收方案数据的功能未触发

ios - 如何根据情况选择rootViewController来启动App?

ios - 如何在 Objective C 中将数组数据从 iPhone 传递到 Apple Watch

iphone - 如何在 coreplot 中创建静态线

ios - UIViewController 在横向模式下显示不正确

ios - 如何从html字符串获取src图像和文本?

ios - 如何在 iOS 中不使用 UIApperance 更改一个类的外观?

iphone - scrollview 不改变 contentOffset

iphone - Interface Builder 无法查看静态库中的类

objective-c - 修改TextEdit,使NSTextView具有透明背景。如何?