How can i control my app’s output volume.
I’ve got an app that uses https://github.com/mattgallagher/AudioStreamer to stream mp3 files from the internet. The AudioStreamer class does not have a way to change output volume and I don’t want to change system volume.
Many apps do this:
- iTunes
- Spotify
- MPlayerX
- Most Audio Players
Edit: If you’re hear about AudioStreamer, I’ve since switched to Apple’s AVPlayer, which i’ve found far simpler and superior. Easy volume adjustment too!
AudioStreamerand I’m guessing most OSX media players use the AudioToolbox framework. AudioToolbox uses a programming interface calledAudioQueueto playback media files. Here is the way to adjust the volume usingAudioQueue.audioQueueis an AudioQueRefkAudioQueueParam_VolumetellsAudioQueueSetParameter()to change the Volume Parameter0.5is the volume from 0.0 – 1.0More details on AudioQueue: https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/AudioQueueReference/Reference/reference.html