【发布时间】:2010-01-06 16:49:51
【问题描述】:
我正在使用以下播放 m4a 文件:
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: fileName];
SystemSoundID soundID;
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
它在模拟器上运行良好,但我在设备上没有听到任何声音。我正在使用的声音文件都保留在捆绑包中。以下是设备上的 filePath 的样子:
file://localhost/var/mobile/Applications/418945F3-3711-4B4D-BC65-0D78993C77FB/African%20Adventure.app/Switch%201.m4a
文件路径是否有问题,或者我需要为设备做些什么不同的事情?
【问题讨论】:
-
确保您的手机没有处于静音模式!我花了 2 个小时才找到这个...
标签: iphone cocoa-touch core-audio