2013-01-02 258 views
0

如果在「touch down」中使用OALSimpleAudio在XCODE中循環播放聲音,並想要在「touch up」時停止該音頻,代碼將如何查看?我嘗試過「stopBg」方法 - 但是這會停止我所有的聲音,並且我有多個聲音在運行,我只希望它停止「sample001」。任何幫助將不勝感激!謝謝!使用OALSimpleAudio停止音頻

- (IBAction爲)sample001Touch {

[[OALSimpleAudio sharedInstance] playEffect:sample001 loop:TRUE]; 

}

- (IBAction爲)sample001Release {

NSLog(@"Stop Please"); 

}

+0

如何是關係到使用IDE這個問題? – Till

回答

1

根據http://kstenerud.github.com/ObjectAL-for-iPhone/documentation/interface_o_a_l_simple_audio.html

- (編號< ALSoundSource>)playEffect:loop:返回ID < ALSoundSource>,並根據http://kstenerud.github.com/ObjectAL-for-iPhone/documentation/protocol_a_l_sound_source-p.html ALSoundSource已停止。只保存一個引用,然後你可以停止它:

@property (nonatomic, strong) id<ALSoundSource> source; 

-

- (IBAction)sample001Touch { 
    self.source = [[OALSimpleAudio sharedInstance] playEffect:sample001 loop:YES]; 
} 

-(IBAction)sample001Release { 
    [self.source stop]; 
    self.source = nil; 
} 
+0

完美。謝謝費爾南多! –