申斥: 我对“我们的方案”相对来说是一个新问题,在我走到一边的时候,我正试图教授自己的基础......这样就是:-
I m building an app that plays a series of .mp3 files strung together using AVAudioplayer. So far, that part is working good. IBActions, and IBOutlets hooked up. Click the button, and the audio plays.
My problem is this: My play button has been added directly to the main.storyboard, set and custom with it s initial state defined in Interface Builder. When I click the play, I want to change the image of the button to indicate that it s playing. However, as soon as the audio starts, it almost seems like the view is... paused, or something. The button image stays the same, until the audio done playing. Only then, will the button image update itself -- hardly useful.
我也只是试图确定另一个随机的UIImageView的形象,该意见并不附属于这个特定纽州。 经验丰富。 一旦我发表我的演剧“阿雷”方法的话, but子就立即工作。
-(IBAction)start_playing:(UIButton*)pressed_button {
[_btn_start setImage:[UIImage imageNamed:@"btn_on-active"] forState:UIControlStateNormal];
[self playAudioArray];
}
我希望我已经离开了足够的时间来继续......。 任何想法/评论/建议?
Thanks a million - Drew
#
<>Update:
我发现,在我的音响上台时,对意见的更新就会中断。 这部法典规定罚款......
if (audioPlayer.playing == YES) {
[audioPlayer pause];
[sender setImage:[UIImage imageNamed:@"btn_on.png"] forState:UIControlStateNormal];
[_btn_stop setImage:[UIImage imageNamed:@"btn_off.png"] forState:UIControlStateNormal];
} else {
NSString *path = [[NSBundle mainBundle] pathForResource:@"audio_file1" ofType:@"mp3"];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
audioPlayer.volume = 1.0;
audioPlayer.numberOfLoops = 0;
[audioPlayer setMeteringEnabled: YES];
[audioPlayer play];
//changes the image when the button is pressed
[sender setImage:[UIImage imageNamed:@"btn_on.png"] forState:UIControlStateNormal];
[_btn_stop setImage:[UIImage imageNamed:@"btn_off.png"] forState:UIControlStateNormal];
}
但该法典的编号如下。
} else {
//changes the image when the button is pressed
[sender setImage:[UIImage imageNamed:@"btn_on.png"] forState:UIControlStateNormal];
[_btn_stop setImage:[UIImage imageNamed:@"btn_off.png"] forState:UIControlStateNormal];
NSArray *theSoundArray = [NSArray arrayWithObjects:@"audio1",@"audio2",@"audio3",nil];
for (int i = 0; i < totalSoundsInQueue;) {
NSString *sound = [theSoundArray objectAtIndex:i];
// Wait until the audio player is not playing anything
while(![audioPlayer isPlaying]){
NSString *path = [[NSBundle mainBundle] pathForResource:@"mom" ofType:@"mp3"];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
audioPlayer.volume = 1.0;
audioPlayer.numberOfLoops = 0;
[audioPlayer setMeteringEnabled: YES];
[audioPlayer play];
i++;
}
}
}
听音响亮,穿透我所有的音响,不发生错误。 我的纽伦州只有把 lo子固定下来。 我用多种不同类型的住宿方法尝试了这一问题。 对于每一个国家而言,尽管......我每次开始通过声音的剪辑,都发挥了巨大作用,但显示显示的焦点却松散。
Which reminds me. Once I m in the loop, my "Stop" button looses it s a clickable (tappable) nature. Until the loop has finished running. If I m not in a loop, the stop button works fine, no problems.
如果我在这里做一整新的错误的话,会问大家什么?