为什么AVAudioPlayer没有响应?

时间:2013-03-13 19:40:57

标签: iphone audio if-statement avaudioplayer audio-streaming

我是iphone开发的新手(Xcode中的第4天),我正在尝试使用AwesomeMenu库实现AvAudioPlayer并控制它。我没有初始化和播放音频的问题,但是当我尝试通过令人敬畏的菜单控件暂停或停止音频时,AVAudioPlayer没有响应。非常感谢任何帮助。

修改

我能够确定我的方法没有在其中执行条件if / else语句。这更令人费解。 didSelectIndex正在触发,但其中的if语句不是。我正确编写条件语句吗?

我的代码:

AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
podcastPlayer = [[AVPlayer playerWithPlayerItem:playerItem] retain];
[podcastPlayer play];

//Control for AvAudioPlayer

- (void)AwesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx{
if (idx==0) {
    if(!podcastPlayer.isPlaying){
        podcastPlayer.play;
    }

}else if(idx==1){
    if(podcastPlayer.isPlaying){
        podcastPlayer.pause;
    }

}else if(idx==2){
    if(podcastPlayer.isPlaying){
        podcastPlayer.stop;
        podcastPlayer.release;

        GSCCAppDelegate *appDelegate = (GSCCAppDelegate *)[[UIApplication sharedApplication] delegate];

        [appDelegate.menu removeFromSuperview];

    }

}else if(idx==3){


}else if(idx==4){

}else if(idx==5){

}

NSLog(@"Select the index : %d",idx);
}

修改

- (void)AwesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx{
if (idx==0) {

    NSLog(@"Index 0"); //Doesn't work

}else if(idx==1){

    NSLog(@"Index 1"); //Doesn't work

}

}

NSLog(@"Select the index : %d",idx); //<--This Works.

}

1 个答案:

答案 0 :(得分:0)

AVPlayerItem *playerItem声明为propertysynthesis

不要声明为本地