iPhone:如何大声播放独立的音量设置,本地通知声音?

编程入门 行业动态 更新时间:2024-10-27 12:28:50
本文介绍了iPhone:如何大声播放独立的音量设置,本地通知声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

借助 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:如何大声播放独立的音量设置,本地通知声音?

本文发布于:2023-11-27 02:00:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636109.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:音量   大声   独立   声音   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!