Question

I am writing an iPad app that uses the "Flite" text-to-speech engine to announce specific events. The Flite engine uses an AVAudioPlayer instance to play the speech audio once it renders. For fun, I decided to add some simple controls to my app to allow the user to control iPod playback (next, prev, play/pause and volume - the basics) while my app is running using MPMusicPlayerController (of course).

The problem I am having is that when I adjust the iPod volume using MPMusicPlayerController, all of my audio is affected, including other sound effects and the speech audio. I set the volume for these other audio players (AVAudioPlayer instances) to 1.0 before playing the sound but it seems that the volume is always capped at whatever the iPod player volume is set to...

Is this normal? And what can I do to get around it? I want my app's audio to play at system full volume regardless of the volume level of the iPod player. (Example: The user had set the system volume to 80% of the device's max. I want my app to play audio at 100% of that 80% while allowing the user to adjust the iPod audio playback to 0-100% of that 80%.) Note: I am not interested in "ducking" but setting the iPod volume lower at all times while my app is running (background music).

I also have the problem, that -sometimes- when you first launch the app and press play on the iPod player (which sends the [player play] call), the iPod does not respond. If I press the home button, go into the iPod app and start playback then, once returning to my app, it works fine. What the deal with that?

Thanks in advance for any help!!

No correct solution

OTHER TIPS

It could be something to do with the audio session category you've specified. Check out the Audio Session Programming Guide to see if you've chosen the right category.

The volume buttons on the side control the system volume and by extension the volume of your app's sounds.

I guess it's considered to be the Master volume control.

you can set the volume for specific samples or sounds using the AVItem's setVolume

[item setVolume]

You can create an AVItem to reference an existing sound file in your application or on the iphone. The code is pretty simple and looks like this -->

AVItem *item [[AVItem alloc] initWithPath:@"the file"]; [item setVolume];

btw, this will not affect the rest of the audio channel (instantiated by some kinda AVController object) and the volume that you've set in your code will not be displayed on you screen so im not sure if you can change it at run time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top