借助 FoneHome 的iPhone应用程序有一个功能,您可以播放声音作为本地通知的一部分。那声音响亮,无论什么iPhone的音量设定在
The FoneHome iPhone app has a feature where you can play a sound as part of a local notification. That sound is loud regardless of what the iPhone's volume level is set at.
这怎么可能获得一个本地通知(或推)播放音频警报是当前iPhone的音量是响亮的独立?我试着只是soundName设置为WAV文件,但它在播放无论当前的音量是的,我看不出有什么选择,否则设置它。
How is it possible to get a local notification (or push) to play an audio alert that is loud independent of what the current iPhone volume level is? I tried just setting the soundName to a WAV file but it plays at whatever the current volume is, and I see no options to set it otherwise.
推荐答案尝试使用以下code
Try using the following code
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; [audioPlayer setVolume:x]; if (audioPlayer == nil) NSLog([error description]); else [audioPlayer play];下面的x是通常范围从0.0到1.0之间的浮点值。但是要提高音量级别分配的x值> 10.0。但是,这样做可能会扭曲的声音有点。
Here 'x' is a floating point value which normally ranges from 0.0 to 1.0. However to increase the Volume level assign x value >10.0. But doing this may distort the sound a bit.
更多推荐
iPhone:如何大声播放独立的音量设置,本地通知声音?
发布评论