76120

iOS sound plays while muted

Question:

I am making a learn-the-alphabet app for toddlers and I have encountered a problem with the sound output. Every sound the app plays when testing on my ipad has the same volume whether the device's sound is set at maximum or mute. In other words, the same sound level comes out regardless of the device's volume setting.

The code I use to play sounds is (using the A-sound as an example):

- (IBAction)aSpill:(id)sender { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"aLyd", CFSTR("wav"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID);

Any help is much appreciated! :)

Answer1:

Please see the answer here <a href="https://stackoverflow.com/questions/10855874/audioservicesplaysystemsound-volume" rel="nofollow">AudioServicesPlaySystemSound Volume?</a> It explains that system sounds don't always use the system volume.

I suggest using AVAudioPlayer to play your sound instead.

Answer2:

So from here : <a href="http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html" rel="nofollow">http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html</a>

Try following the code using the below kind of code.

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"sound" ofType: @"wav"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil]; [fileURL release]; self.player = newPlayer; [newPlayer release]; [player prepareToPlay];

It is about halfway down the page.

Recommend

  • JButton background images
  • Rails: Include all of model A and only a subset of related model B
  • ON INSERT: Cannot add an entity with a key that is already in use
  • Row versioning for MySql
  • Pulling through text into div
  • Load Class files over the network with Reflections
  • When activating OLEControl in my PowerBuilder application, toolbar items disappear
  • AVAudioPlayer doesn't load sound
  • Replacing points of color by a uniform colored surface
  • C# String Filepath Question
  • How to implement AVAudioPlayer Inside Singleton Method?
  • XMLHttpRequest in IE-7
  • How can I declare inList constraints from a controller in Grails?
  • Python `no module pip.__main__;` error when trying to install a module
  • Is there a way to limit the number of records in certain collection
  • windowScriptObject method not found on Objective-C code
  • Subviews for custom UIView with Nib (.xib) don't load?
  • file read() const correctness
  • How do I create a new row inside an angular ng-repeat?
  • Implementing an abstract function with access types in Ada
  • How can I see a list of all files that are different between two Hg repositories?
  • Receive mouse move even cursor is outside control
  • What is the difference between a “service account” and an “installed application”?
  • Request response issues in biztalk
  • Click on button in another program - FindWindow, C#
  • Clear fused location provider's location for testing
  • Overlapping controls in Windows XP
  • c# open webrowser in many tab
  • Limiting recursion to certain level - Duplicate rows
  • How to Cache Real-time Data?
  • Adding custom controls to a full screen movie
  • AT Commands to Send SMS not working in Windows 8.1
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How to stop GridView from loading again when I press back button?
  • How can I remove ASP.NET Designer.cs files?
  • java string with new operator and a literal