title: How to set app volume separately from system volume ( iOS device volume physical keys )?
body: <p>Our app is able to play music on a wifi speaker. One of the features of the app is changing the volume of speaker through pressing volume + / volume - hard keys on the iPhone.</p>
  
  <p>The logic behind this is getting the volume value of the system and send it to the speaker. </p>
  
  <p>However, the problem is that this function affects the system volume. Is there anyway to avoid adjusting the system volume when pressing the volume keys while inside the app?</p>
  
  <p>This is the code that I used to get the system volume on every press:</p>
  
  <pre><code>- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
  {
      if ([keyPath isEqual:@"outputVolume"])
      {
          CGFloat phoneVolume = [[AVAudioSession sharedInstance] outputVolume];
          NSInteger volume = 100 * phoneVolume;
  
          [self onHardKeyVolumeChange:volume];
      }
  }
  </code></pre>
  
  <p>Thanks.</p>