2011-02-10 7 views

答えて

0
- (IBAction)startPlayback:(UIButton *)sender { 
      
          NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; 
          resourcePath = [resourcePath stringByAppendingString:@"/grabbag.m4a"]; 
          NSLog(@"Path to play: %@", resourcePath); 
          NSError* err; 

        
          player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:resourcePath] error:&err]; 

          if(err){ 
              //bail! 
              NSLog(@"Failed with reason: %@", [err localizedDescription]); 
          } 
          else{ 
              player.delegate = self; 
              [player play]; 
          } 
      
    } 
0
- (IBAction)startPlayback:(UIButton *)sender { 
  
      NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; 
      resourcePath = [resourcePath stringByAppendingString:@"/grabbag.m4a"]; 
      NSLog(@"Path to play: %@", resourcePath); 
      NSError* err; 

    
      player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:resourcePath] error:&err]; 

      if(err){ 
          //bail! 
          NSLog(@"Failed with reason: %@", [err localizedDescription]); 
      } 
      else{ 
          player.delegate = self; 
          [player play]; 
      } 
  
} 
+0

コードをコピーして貼り付けるだけではできません。スタックオーバーフローの書式設定オプションを使用する必要があります。正してください。 –

1

クラスのメソッド- (void)playInputClickを使用できます。静的メソッド+ (UIDevice *)currentDeviceを使用して、このクラスのインスタンスにアクセスできます。このメソッドを使用して、デフォルトの入力サウンドを独自のカスタムUIにアタッチします。