marko marko - 10 days ago 8
Objective-C Question

Turn off sound in iPhone Simulator

Is there an option to turn off sound, in

iPhone Simulator
?
Or to adjust volume?

Answer

Partial Success - There are no good options

The iPhone Simulator selects the currently selected output at launch. Using Soundflower plugin and sending the audio to nowhere I started the iPhone Simulator. If you then switch to a different, working, output the simulator will remain 'muted' until you restart the simulator. So in general, you can attempt to trick the simulator to output to a dead end output.

Experimental setup - A sample video player

I'm working on a solution to this problem and as a first step created a demonstration video player app. You can download VideoPlayer from GitHub for your own experiments.

First Attempt - Use a 3rd party app to mute it

Tried using Audio Hijack Pro by Rogue Amoeba to hijack the audio stream and mute it. This didn't work and crashes the simulator. Contacted support and they reported that iPhone Simulator does some things that prevent them from hijacking the audio. I also looked into Soundflower and Jack.

Second Attempt - In-app mute

I was thinking maybe you could make a debug option where when in the app and on the simulator sound would be muted. However, within an app, only private APIs have the power to mute or reduce volume for the device. In the book iPhone Open Application Development Chapter 6, Example "What's My Volume' gives sample code for manipulating system-wide sound through the AVSystemController. It might be fun to explore this route, but to make it into a weaponized tool would require a lot of trouble since you need to compile against private headers.

Idea Three

Find a command-line option to pass to the Springboard or iPhone Simulator that will mute sound, or re-enable the volume control within the simulator, and of course be able to still launch the debugger.

Enhancement Request

I filed an Apple Bug Report enhancement request for both iPhone Simulator volume control, request 13428429, and per application volume control in Mac OS X, request 13428420. If you want these features, please file your own bug.

Comments