iPhone(SDK 2.2):adusting播放音量,而没有积极播放音乐瓦特/ AVFoundation? [英] iPhone (SDK 2.2): adusting playback volume while NOT actively playing music w/ AVFoundation?

查看:153
本文介绍了iPhone(SDK 2.2):adusting播放音量,而没有积极播放音乐瓦特/ AVFoundation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有起着许多短期声音剪辑的应用程序。我需要知道什么时候声音播放完毕,我需要使用MP3音乐,所以我使用AVFoundation的声音回放。

So I have an app which plays many short sound clips. I need to know when the sounds are finished playing, and I need to use mp3s, so I'm using AVFoundation for the sound playback.

当一个声音积极发挥,并在用户使用硬件音量按钮,重放音量的变化。问题是,应用程序是不是经常播放声音,当它不是,且使用的硬件按键,铃声音量调整被代替。

When a sound is actively playing, and the user uses the hardware volume buttons, the playback volume changes. Problem is, the app is NOT constantly playing sounds, and when it's not, and the hardware buttons are used, the RINGER volume gets adjusted instead.

我如何设置它的话,只要在应用程序运行时,用户可以调整播放音量?

How do I set it up so, as long as the app is running, the user can adjust the playback volume?

谢谢!

推荐答案

原来这可以通过分配一个 AVAudioPlayer 与任何有效的声音文件来完成并调用 prepareToPlay 方法,而没有调用播放方法。

Turns out this can be accomplished by allocating an AVAudioPlayer with any valid sound file and calling the prepareToPlay method, without ever calling the play method.

完美的作品。

这篇关于iPhone(SDK 2.2):adusting播放音量,而没有积极播放音乐瓦特/ AVFoundation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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