我正在使用以下代码播放声音
NSString *laughSoundPath = [[NSBundle mainBundle]pathForResource:@"laugh" ofType:@"wav"];
NSURL *laughURL = [[NSURL alloc]initFileURLWithPath:laughSoundPath];
laughTone = [[AVAudioPlayer alloc]initWithContentsOfURL:laughURL error:nil];
[laughTone prepareToPlay];
[laughTone setDelegate:self];
[laughURL release];
-(IBAction)play
{
[laughTone play];
}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下线来停止声音
-(IBAction)stop
{
[laughTone stop];
}
Run Code Online (Sandbox Code Playgroud)
问题是..当我再次播放声音时,它从停止的位置开始...我的意思是说它的工作暂停..帮助我
-(IBAction)stop
{
[laughTone stop];
[laughTone playAtTime:0];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
228 次 |
| 最近记录: |