2017-04-12 24 views

答えて

1

..

- (void)viewWillAppear:(BOOL)animated { 

     AVAudioSession* audioSession = [AVAudioSession sharedInstance]; 

     [audioSession setActive:YES error:nil]; 
     [audioSession addObserver:self 
         forKeyPath:@"outputVolume" 
          options:0 
          context:nil]; 
    } 

    -(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 

     if ([keyPath isEqual:@"outputVolume"]) { 
      NSLog(@"volume changed"); 
     } 
    } 

とAndroid。

@Override 
public boolean dispatchKeyEvent(KeyEvent event) { 
    int action = event.getAction(); 
    int keyCode = event.getKeyCode(); 
     switch (keyCode) { 
     case KeyEvent.KEYCODE_VOLUME_UP: 
      if (action == KeyEvent.ACTION_DOWN) { 
       //TODO 
      } 
      return true; 
     case KeyEvent.KEYCODE_VOLUME_DOWN: 
      if (action == KeyEvent.ACTION_DOWN) { 
       //TODO 
      } 
      return true; 
     default: 
      return super.dispatchKeyEvent(event); 
     } 
    } 
関連する問題