声音在模拟器,但不是设备 [英] Sound on simulator but not device

查看:117
本文介绍了声音在模拟器,但不是设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下方式播放m4a文件:

I'm using the following to play an m4a file:

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: fileName];
SystemSoundID soundID;
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);

它在模拟器上正常工作,但我在设备上什么也听不到。我使用的声音文件都留在包中。这里是从设备filePath看起来像:

It works fine on the simulator but I hear nothing on the device. Sounds files I'm using all stay in the bundle. Here is what filePath looks like from the device:

file://localhost/var/mobile/Applications/418945F3-3711-4B4D-BC65-0D78993C77FB/African%20Adventure.app/Switch%201.m4a

是否有问题与文件路径或任何不同我需要为设备做什么?

Is there an issue with the file path or any thing different I need to do for the device?

推荐答案

正如一个侧面 - 完全相同的问题,花了大概接近一个小时将文件转换为正确的格式,等等。但问题是在iPad上的静音开关。因此,即使音量已经上升,我可以听到iPad上的其他声音,因为静音开关已打开,它不会播放系统声音。

Just as a sidenote - I was having the exact same problem and spent probably close to an hour on converting files to the correct format, etc.. Yet the problem was the "mute" switch on the iPad. So even though the volume was up, and I could hear other sounds on the iPad, because the mute switch was turned on, it wasn't playing system sounds.

添加到混乱,这个应用程序使用文本到语音和来自听写的音量是完全正常,只有来自AudioServicesPlaySystemSound()的声音没有被播放。

To add to the confusion, this app uses text-to-speech and the volume coming from the dictation was perfectly fine, it was only the sounds coming from AudioServicesPlaySystemSound() that weren't being played.

这篇关于声音在模拟器,但不是设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆